#include "../src/distribution.c"
#include "../src/qfunc.c"

#include <assert.h>
#include <stdio.h>

typedef struct _LogPRatingTestDatum LogPRatingTestDatum ;
struct _LogPRatingTestDatum 
{ 
  struct
    {
      unsigned int      rating;
      float            loga[5];
      float            logbeta;
      float            c[5];
      float            d[5 * 4];
    }                                   inputs;
  float                                desired_output;
};

static void
test_logprating (void)
{
  LogPRatingTestDatum data[] = 
    {{{3, {0.784773, 0.752035, 0.764494, 0.212136, 0.427554}, 0.0755713, {0.356801, 0.628868, 0.523907, 0.0118933, 0.625807}, {0.0637991, 0.895345, 0.00268126, 0.504391, 0.290164, 0.261661, 0.785842, 0.812285, 0.25249, 0.978708, 0.370125, 0.1318, 0.382939, 0.193935, 0.618089, 0.367306, 0.170803, 0.766381, 0.542518, 0.0105056}}, -1.43293}, {{3, {0.541934, 0.242474, 0.530625, 0.384698, 0.478135}, 0.347129, {0.527943, 0.880307, 0.187971, 0.0854685, 0.742101}, {0.068022, 0.935481, 0.10676, 0.371976, 0.936222, 0.552542, 0.912825, 0.753887, 0.568915, 0.38174, 0.146444, 0.211369, 0.55841, 0.839805, 0.90397, 0.680745, 0.173711, 0.36167, 0.55684, 0.152802}}, -1.06314}, {{2, {0.293404, 0.173699, 0.471372, 0.410701, 0.225382}, 0.238218, {0.364611, 0.0387244, 0.28916, 0.685676, 0.451786}, {0.284837, 0.720245, 0.303936, 0.305342, 0.0734677, 0.161835, 0.464131, 0.401373, 0.392723, 0.988124, 0.102461, 0.844532, 0.239921, 0.69472, 0.928762, 0.373161, 0.82922, 0.469338, 0.690544, 0.00854922}}, -1.77294}, {{3, {0.790496, 0.180177, 0.00486819, 0.556763, 0.505659}, 0.459932, {0.700932, 0.251421, 0.432191, 0.298097, 0.236801}, {0.850048, 0.0394685, 0.309973, 0.134341, 0.005516, 0.799547, 0.615253, 0.205579, 0.632355, 0.970327, 0.145915, 0.515035, 0.623806, 0.179831, 0.965738, 0.510167, 0.067043, 0.674172, 0.505806, 0.809235}}, -1.03627}, {{1, {0.815622, 0.24198, 0.207709, 0.572433, 0.965574}, 0.202512, {0.897736, 0.438093, 0.960058, 0.402965, 0.282483}, {0.232514, 0.327702, 0.432638, 0.136568, 0.717479, 0.703896, 0.252807, 0.170829, 0.207312, 0.636853, 0.578636, 0.665023, 0.398077, 0.821231, 0.336655, 0.457314, 0.825644, 0.855658, 0.134143, 0.559578}}, -2.47074}, {{2, {0.387551, 0.8956, 0.731179, 0.277095, 0.155037}, 0.567898, {0.298541, 0.140527, 0.437559, 0.864001, 0.0457338}, {0.969698, 0.230247, 0.227148, 0.467098, 0.304675, 0.83217, 0.405917, 0.130443, 0.847361, 0.00652603, 0.55026, 0.9963, 0.287783, 0.618975, 0.65466, 0.265121, 0.0106882, 0.463937, 0.0867619, 0.96658}}, -1.5387}, {{2, {0.870161, 0.0263786, 0.22276, 0.920846, 0.900464}, 0.796132, {0.995612, 0.453748, 0.595789, 0.963962, 0.589695}, {0.323305, 0.748428, 0.957436, 0.0394355, 0.327005, 0.460646, 0.338461, 0.384776, 0.061884, 0.449957, 0.874524, 0.298014, 0.0953039, 0.579796, 0.848145, 0.0752537, 0.174458, 0.679333, 0.0520133, 0.0796416}}, -10.0093}, {{0, {0.72071, 0.0835437, 0.0880516, 0.489947, 0.397405}, 0.335115, {0.130616, 0.450511, 0.0703997, 0.87447, 0.792155}, {0.065735, 0.00851566, 0.424512, 0.917631, 0.767721, 0.913212, 0.844716, 0.0694865, 0.692467, 0.738754, 0.165383, 0.0174731, 0.612826, 0.0180444, 0.0818395, 0.929422, 0.122879, 0.62064, 0.746724, 0.798806}}, -1.2393}, {{2, {0.672368, 0.55024, 0.872255, 0.00665081, 0.606633}, 0.541724, {0.447743, 0.0890194, 0.838912, 0.628513, 0.603027}, {0.0195329, 0.146445, 0.889759, 0.437644, 0.00205979, 0.533619, 0.871714, 0.355804, 0.0726382, 0.41074, 0.251074, 0.60908, 0.273832, 0.738372, 0.700834, 0.736825, 0.267182, 0.131739, 0.15911, 0.289083}}, -2.68549}, {{1, {0.178162, 0.292827, 0.530598, 0.686056, 0.158629}, 0.146382, {0.640839, 0.248412, 0.15657, 0.612762, 0.769125}, {0.892608, 0.0839313, 0.202022, 0.518051, 0.283528, 0.810099, 0.46365, 0.817216, 0.546703, 0.542917, 0.331911, 0.658106, 0.257621, 0.364755, 0.0390841, 0.127508, 0.571565, 0.206126, 0.892702, 0.486669}}, -1.10067}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
#define logafunc(n) data[i].inputs.loga[n]
#define cfunc(n) data[i].inputs.c[n]
#define dfunc(n, k) data[i].inputs.d[4 * n + k]
      float output = logprating (data[i].inputs.rating,
                                  logafunc,
                                  5,
                                  data[i].inputs.logbeta,
                                  cfunc,
                                  dfunc,
                                  4);
#undef dfunc
#undef cfunc
#undef logafunc

      assert (fabs (output - data[i].desired_output) <=
              1e-3 * (1 + fabs (output) + fabs (data[i].desired_output)) ||
              (fprintf (stderr, "%g ?= %g\n", output, data[i].desired_output),
               0));
    }
}

typedef struct _DLogPRatingDLogaTestDatum DLogPRatingDLogaTestDatum;
struct _DLogPRatingDLogaTestDatum 
{ 
  struct
    {
      unsigned int      rating;
      float            loga[5];
      float            logbeta;
      float            c[5];
      float            d[5 * 4];
    }                                   inputs;
  float                                desired_output[5];
};

static void
test_dlogpratingdloga (void)
{
  DLogPRatingDLogaTestDatum data[] = 
    {{{2, {0.192956, 0.870415, 0.871021, 0.378444, 0.810678}, 0.270102, {0.258413, 0.0960859, 0.086506, 0.927409, 0.010559}, {0.852812, 0.489843, 0.156281, 0.968831, 0.502241, 0.379849, 0.708306, 0.976659, 0.431609, 0.987399, 0.690875, 0.950111, 0.438897, 0.794443, 0.82046, 0.07909, 0.060453, 0.983765, 0.550358, 0.820677}}, {0.232769, -0.0022281, 0.0191599, -0.710165, 0.000914889}}, {{2, {0.964367, 0.897259, 0.622949, 0.810118, 0.111555}, 0.407417, {0.466668, 0.841287, 0.609315, 0.0275684, 0.758362}, {0.864628, 0.177705, 0.0401694, 0.0674876, 0.914517, 0.738808, 0.245726, 0.247028, 0.835427, 0.678355, 0.261961, 0.696669, 0.0147497, 0.713988, 0.364701, 0.0737197, 0.204632, 0.602433, 0.957284, 0.607051}}, {0.0588783, 0.13481, 0.348329, -0.00875625, -0.216614}}, {{3, {0.363344, 0.993118, 0.929716, 0.848689, 0.498716}, 0.815413, {0.889547, 0.781201, 0.584199, 0.0766047, 0.64382}, {0.534174, 0.748772, 0.398249, 0.38186, 0.837505, 0.734022, 0.684261, 0.0171584, 0.763785, 0.529391, 0.0818284, 0.059874, 0.156733, 0.166046, 0.0887102, 0.130158, 0.308044, 0.667331, 0.273297, 0.240611}}, {0.00287928, 0.112978, 0.0060658, -0.000538294, 0.00360524}}, {{2, {0.526843, 0.0831318, 0.196692, 0.596791, 0.992669}, 0.33436, {0.798443, 0.214931, 0.155164, 0.600338, 0.114182}, {0.197773, 0.39138, 0.0709471, 0.0323533, 0.137899, 0.234646, 0.904901, 0.943643, 0.00774103, 0.926602, 0.23757, 0.670346, 0.76713, 0.399759, 0.154438, 0.473653, 0.170338, 0.407089, 0.820078, 0.67521}}, {0.140102, -0.0884134, 0.0459867, 0.376994, -0.105006}}, {{3, {0.955407, 0.251925, 0.219741, 0.561029, 0.757634}, 0.860545, {0.148794, 0.528675, 0.619735, 0.625899, 0.243893}, {0.585032, 0.611994, 0.699298, 0.00632287, 0.914686, 0.844864, 0.299539, 0.851885, 0.441033, 0.674526, 0.89245, 0.0318063, 0.765823, 0.719119, 0.640525, 0.812066, 0.204794, 0.961485, 0.779979, 0.663272}}, {0.288038, -0.135159, 0.558526, -0.128347, -0.0849989}}, {{3, {0.676119, 0.34175, 0.15408, 0.419379, 0.0910865}, 0.729756, {0.454782, 0.413056, 0.1764, 0.884892, 0.155243}, {0.561172, 0.735367, 0.210366, 0.262793, 0.529365, 0.969544, 0.491247, 0.622269, 0.7173, 0.76475, 0.529762, 0.842289, 0.0540276, 0.0886311, 0.188012, 0.688209, 0.634648, 0.997545, 0.458256, 0.233427}}, {0.214933, -0.0696981, -0.0861141, -1.41623, 0.111266}}, {{0, {0.221592, 0.821145, 0.573364, 0.0781842, 0.66042}, 0.0857778, {0.362998, 0.815391, 0.131055, 0.116234, 0.871751}, {0.193122, 0.413755, 0.351484, 0.341988, 0.350833, 0.359727, 0.262853, 0.153976, 0.662624, 0.725079, 0.265308, 0.69572, 0.429197, 0.503487, 0.444164, 0.122356, 0.351012, 0.843067, 0.358386, 0.759358}}, {0.056261, -0.147532, -0.034079, -0.00693481, 0.259613}}, {{2, {0.535622, 0.712012, 0.242152, 0.887607, 0.342499}, 0.298257, {0.890668, 0.545619, 0.991666, 0.938529, 0.627815}, {0.391643, 0.329042, 0.21345, 0.362507, 0.695923, 0.899846, 0.709963, 0.918343, 0.573568, 0.548833, 0.866897, 0.559958, 0.81421, 0.0132119, 0.154885, 0.317806, 0.926602, 0.670713, 0.856628, 0.427138}}, {0.198361, 0.209475, -0.401254, -0.0270902, -0.222041}}, {{3, {0.380983, 0.679046, 0.918099, 0.799322, 0.98934}, 0.350004, {0.704649, 0.436815, 0.293417, 0.450158, 0.994685}, {0.518472, 0.719849, 0.901325, 0.127789, 0.958514, 0.905639, 0.888113, 0.972904, 0.640709, 0.979037, 0.2174, 0.116276, 0.213571, 0.598054, 0.538354, 0.198177, 0.414248, 0.608714, 0.18835, 0.493529}}, {0.479458, -0.036844, 0.172068, 0.165306, -0.390211}}, {{2, {0.977433, 0.315297, 0.738192, 0.498843, 0.458961}, 0.595448, {0.836867, 0.371055, 0.500447, 0.689809, 0.948754}, {0.398151, 0.859738, 0.710772, 0.731354, 0.281875, 0.646167, 0.112718, 0.193001, 0.0836976, 0.231919, 0.504005, 0.00465095, 0.590169, 0.254486, 0.188708, 0.266459, 0.0913255, 0.795525, 0.59326, 0.429592}}, {-0.896566, 0.136867, -0.770405, 0.637669, -1.07351}}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float tmpdloga[5];
      float tmpdc[5];
      float tmpdd[5 * 4];
#define logafunc(n) data[i].inputs.loga[n]
#define cfunc(n) data[i].inputs.c[n]
#define dfunc(n, k) data[i].inputs.d[4 * n + k]
      dlogpratingdall (tmpdloga,
                       tmpdc,
                       tmpdd,
                       data[i].inputs.rating,
                       logafunc,
                       5,
                       data[i].inputs.logbeta,
                       cfunc,
                       dfunc,
                       4);
#undef dfunc
#undef cfunc
#undef logafunc

      for (unsigned int j = 0; j < 5; ++j)
        {
          assert (fabs (tmpdloga[j] - data[i].desired_output[j]) <=
                  1e-3 * (1 + fabs (tmpdloga[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", tmpdloga[j], data[i].desired_output[j]),
                   0));
        }
    }
}

static void
test_dlogpratingdlogbeta (void)
{
  LogPRatingTestDatum data[] = 
    {{{2, {0.976156, 0.441209, 0.449671, 0.806979, 0.551252}, 0.579034, {0.755037, 0.428593, 0.800046, 0.918827, 0.0705727}, {0.61172, 0.577108, 0.736248, 0.490597, 0.276674, 0.781599, 0.72007, 0.293613, 0.779584, 0.941541, 0.385372, 0.390163, 0.705598, 0.965385, 0.944164, 0.940492, 0.898619, 0.414133, 0.36513, 0.185455}}, -0.954112}, {{0, {0.470026, 0.614087, 0.446303, 0.114883, 0.858305}, 0.0369789, {0.710055, 0.624285, 0.581631, 0.25538, 0.989985}, {0.330673, 0.802047, 0.31384, 0.604612, 0.940509, 0.0964491, 0.348455, 0.660449, 0.0000170971, 0.19783, 0.934322, 0.295319, 0.814562, 0.727804, 0.320235, 0.849016, 0.699679, 0.869499, 0.283256, 0.138962}}, -0.770114}, {{1, {0.0753936, 0.287868, 0.0278761, 0.148977, 0.744721}, 0.48582, {0.714036, 0.544364, 0.804212, 0.389371, 0.365582}, {0.883916, 0.804194, 0.191541, 0.43126, 0.588597, 0.989633, 0.463737, 0.111025, 0.73958, 0.289954, 0.594238, 0.827768, 0.600619, 0.21456, 0.30637, 0.799892, 0.451642, 0.469839, 0.82055, 0.0858559}}, -0.429031}, {{3, {0.907277, 0.665628, 0.431179, 0.720274, 0.0233617}, 0.861433, {0.239638, 0.289015, 0.434765, 0.8718, 0.775901}, {0.17799, 0.695185, 0.581847, 0.181663, 0.350222, 0.0945665, 0.367287, 0.875293, 0.550329, 0.642925, 0.897447, 0.0547427, 0.464473, 0.735647, 0.23182, 0.623564, 0.744199, 0.712286, 0.370387, 0.383925}}, -0.0961647}, {{3, {0.455185, 0.27752, 0.498586, 0.608024, 0.277195}, 0.582335, {0.91674, 0.426361, 0.926973, 0.487769, 0.549453}, {0.551068, 0.376644, 0.844844, 0.652006, 0.496325, 0.912171, 0.109197, 0.420186, 0.872762, 0.167972, 0.396911, 0.0497994, 0.488836, 0.712787, 0.119391, 0.551213, 0.880812, 0.435592, 0.537056, 0.634473}}, 0.204682}, {{1, {0.454451, 0.508619, 0.0492869, 0.0850202, 0.903383}, 0.131975, {0.204443, 0.433014, 0.407058, 0.219805, 0.095246}, {0.0128283, 0.534296, 0.0518331, 0.698335, 0.963029, 0.0454599, 0.339046, 0.578944, 0.411816, 0.164648, 0.903454, 0.0418879, 0.777343, 0.710197, 0.394834, 0.992601, 0.692322, 0.806814, 0.262859, 0.788158}}, 0.275231}, {{0, {0.259308, 0.399756, 0.0430541, 0.692912, 0.24648}, 0.86546, {0.991221, 0.994578, 0.283451, 0.82, 0.652175}, {0.415634, 0.871635, 0.655352, 0.748722, 0.373746, 0.0942921, 0.945155, 0.353887, 0.381145, 0.40197, 0.138341, 0.0910285, 0.592987, 0.142662, 0.738586, 0.0479744, 0.900075, 0.896182, 0.873126, 0.0567533}}, -2.67343}, {{2, {0.905497, 0.612731, 0.0531266, 0.404578, 0.489863}, 0.741096, {0.397775, 0.655857, 0.116117, 0.646804, 0.45262}, {0.301969, 0.734972, 0.244835, 0.314279, 0.210941, 0.141985, 0.102173, 0.575693, 0.162966, 0.241911, 0.205991, 0.702567, 0.106213, 0.336414, 0.59326, 0.64944, 0.701635, 0.84655, 0.852163, 0.251665}}, -0.291858}, {{2, {0.0457783, 0.730433, 0.205359, 0.799045, 0.743809}, 0.995461, {0.960525, 0.484767, 0.532868, 0.853475, 0.858352}, {0.909074, 0.369902, 0.611565, 0.652361, 0.206507, 0.263689, 0.275151, 0.0591007, 0.557067, 0.562054, 0.428601, 0.206937, 0.305402, 0.516276, 0.698168, 0.00157816, 0.506356, 0.772467, 0.702707, 0.0410536}}, -7.64653}, {{1, {0.0215899, 0.239598, 0.849232, 0.182702, 0.112516}, 0.869697, {0.237667, 0.530341, 0.906009, 0.606008, 0.962516}, {0.471241, 0.348943, 0.0439538, 0.533915, 0.264303, 0.043541, 0.527678, 0.835747, 0.262725, 0.537185, 0.755212, 0.13304, 0.221672, 0.515595, 0.515613, 0.283808, 0.0389696, 0.403078, 0.645917, 0.0461409}}, -2.10106}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float tmpdloga[5];
      float tmpdc[5];
      float tmpdd[5 * 4];
#define logafunc(n) data[i].inputs.loga[n]
#define cfunc(n) data[i].inputs.c[n]
#define dfunc(n, k) data[i].inputs.d[4 * n + k]
      float output = dlogpratingdall (tmpdloga,
                                       tmpdc,
                                       tmpdd,
                                       data[i].inputs.rating,
                                       logafunc,
                                       5,
                                       data[i].inputs.logbeta,
                                       cfunc,
                                       dfunc,
                                       4);
#undef dfunc
#undef cfunc
#undef logafunc

      assert (fabs (output - data[i].desired_output) <=
              1e-3 * (1 + fabs (output) + fabs (data[i].desired_output)) ||
              (fprintf (stderr, "%g ?= %g\n", output, data[i].desired_output),
               0));
    }
}

static void
test_dlogpratingdc (void)
{
  DLogPRatingDLogaTestDatum data[] = 
    {{{3, {0.625458, 0.192417, 0.987653, 0.617899, 0.0689751}, 0.235869, {0.4304, 0.0419431, 0.517143, 0.869491, 0.127632}, {0.654695, 0.23177, 0.594437, 0.62039, 0.860707, 0.375989, 0.0396547, 0.408226, 0.970169, 0.00104666, 0.806992, 0.631401, 0.27231, 0.375588, 0.614575, 0.643748, 0.654412, 0.306613, 0.378706, 0.213348}}, {-0.669183, -0.0114146, -1.40918, -0.550764, 0.16787}}, {{1, {0.612469, 0.78947, 0.509215, 0.0857159, 0.957773}, 0.557701, {0.914778, 0.465326, 0.0970665, 0.181712, 0.875123}, {0.0571002, 0.126897, 0.180665, 0.0681309, 0.4257, 0.854587, 0.805077, 0.453556, 0.781952, 0.200175, 0.498464, 0.0748502, 0.568603, 0.587707, 0.708993, 0.565635, 0.482887, 0.629934, 0.151293, 0.650857}}, {-0.0308036, -0.878692, 0.835798, 0.0796915, -1.12465}}, {{2, {0.0175614, 0.532867, 0.969581, 0.775734, 0.960461}, 0.40597, {0.788916, 0.707603, 0.534762, 0.551383, 0.98384}, {0.254047, 0.75281, 0.351207, 0.485376, 0.179197, 0.184207, 0.763501, 0.776383, 0.613562, 0.70132, 0.133567, 0.62509, 0.962705, 0.683758, 0.6007, 0.655509, 0.186971, 0.723297, 0.19473, 0.866593}}, {-0.0310317, -0.601617, 0.800633, 0.446399, 0.09138}}, {{2, {0.479368, 0.188536, 0.643347, 0.882753, 0.225321}, 0.435726, {0.29214, 0.397377, 0.0461235, 0.251519, 0.528639}, {0.620995, 0.432561, 0.550199, 0.395072, 0.995905, 0.469857, 0.86644, 0.794372, 0.340396, 0.282886, 0.143143, 0.599642, 0.473803, 0.803518, 0.954608, 0.956295, 0.59105, 0.578197, 0.518882, 0.664155}}, {-0.128869, -0.207814, 0.556039, -0.649262, 0.130648}}, {{0, {0.193673, 0.532074, 0.267364, 0.135516, 0.572679}, 0.0995125, {0.717165, 0.740444, 0.576774, 0.629656, 0.850724}, {0.946072, 0.236378, 0.34677, 0.707581, 0.34643, 0.762575, 0.543252, 0.752973, 0.390135, 0.171525, 0.965055, 0.234091, 0.72598, 0.977852, 0.432981, 0.966728, 0.590463, 0.405173, 0.333468, 0.249563}}, {-0.584735, 0.50398, 0.116003, 0.0435986, -0.405659}}, {{1, {0.850019, 0.828399, 0.703812, 0.398839, 0.903947}, 0.592021, {0.357042, 0.691258, 0.557517, 0.829446, 0.81379}, {0.938284, 0.167382, 0.657921, 0.848736, 0.704193, 0.441403, 0.680069, 0.415755, 0.737465, 0.85094, 0.274896, 0.0822868, 0.487902, 0.000920404, 0.446498, 0.378474, 0.0890632, 0.0969733, 0.854477, 0.0214321}}, {1.52996, -0.0106057, -1.4083, 0.548857, -0.137219}}, {{0, {0.397805, 0.539456, 0.025031, 0.207642, 0.459521}, 0.372074, {0.36711, 0.358906, 0.755328, 0.930671, 0.687041}, {0.943151, 0.0178631, 0.0797315, 0.412144, 0.860864, 0.529961, 0.0788111, 0.965647, 0.48239, 0.440898, 0.981838, 0.11117, 0.460958, 0.0430925, 0.442382, 0.0861387, 0.253316, 0.583571, 0.0703079, 0.719029}}, {-1.57509, -0.891873, 0.112821, -0.417352, 0.351789}}, {{2, {0.89441, 0.828243, 0.139637, 0.0319882, 0.951259}, 0.81038, {0.0599054, 0.619844, 0.0903945, 0.280419, 0.981094}, {0.654198, 0.608005, 0.839521, 0.999257, 0.543028, 0.147047, 0.796429, 0.556875, 0.456889, 0.893731, 0.212857, 0.486567, 0.73786, 0.999321, 0.384614, 0.34693, 0.705872, 0.0480626, 0.574234, 0.287025}}, {-1.06391, -3.10517, 1.64017, 1.27176, -2.87981}}, {{0, {0.0860281, 0.957668, 0.293815, 0.30593, 0.43183}, 0.349663, {0.454294, 0.306674, 0.888803, 0.202617, 0.657865}, {0.749799, 0.431914, 0.308885, 0.445008, 0.263232, 0.694053, 0.309564, 0.0603935, 0.916302, 0.988181, 0.261502, 0.486159, 0.629277, 0.902153, 0.303833, 0.192345, 0.323346, 0.470322, 0.95417, 0.738051}}, {-0.455764, -0.0900784, -0.721636, -0.489104, 0.841629}}, {{1, {0.0166726, 0.58152, 0.751553, 0.0801859, 0.266874}, 0.149606, {0.442668, 0.635178, 0.00364166, 0.455553, 0.133104}, {0.574785, 0.0873399, 0.467372, 0.871602, 0.0886253, 0.458063, 0.565219, 0.567769, 0.896281, 0.134716, 0.0948967, 0.613599, 0.15823, 0.118044, 0.513377, 0.862045, 0.0780439, 0.85117, 0.363771, 0.419377}}, {0.427779, -0.250077, 0.895677, 0.220826, -0.695009}}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float tmpdloga[5];
      float tmpdc[5];
      float tmpdd[5 * 4];
#define logafunc(n) data[i].inputs.loga[n]
#define cfunc(n) data[i].inputs.c[n]
#define dfunc(n, k) data[i].inputs.d[4 * n + k]
      dlogpratingdall (tmpdloga,
                       tmpdc,
                       tmpdd,
                       data[i].inputs.rating,
                       logafunc,
                       5,
                       data[i].inputs.logbeta,
                       cfunc,
                       dfunc,
                       4);
#undef dfunc
#undef cfunc
#undef logafunc

      for (unsigned int j = 0; j < 5; ++j)
        {
          assert (fabs (tmpdc[j] - data[i].desired_output[j]) <=
                  1e-3 * (1 + fabs (tmpdc[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", tmpdc[j], data[i].desired_output[j]),
                   0));
        }
    }
}

typedef struct _DLogPRatingDdTestDatum DLogPRatingDdTestDatum;
struct _DLogPRatingDdTestDatum 
{ 
  struct
    {
      unsigned int      rating;
      float            loga[5];
      float            logbeta;
      float            c[5];
      float            d[5 * 4];
    }                                   inputs;
  float                                desired_output[5 * 4];
};

static void
test_dlogpratingdd (void)
{
  DLogPRatingDdTestDatum data[] = 
    {{{2, {0.535064, 0.261384, 0.131534, 0.695388, 0.539058}, 0.991974, {0.786979, 0.441131, 0.229273, 0.678764, 0.676724}, {0.899762, 0.0224232, 0.87039, 0.831291, 0.51447, 0.636702, 0.988868, 0.00842839, 0.576033, 0.887747, 0.97893, 0.697751, 0.557214, 0.352683, 0.717546, 0.566217, 0.861825, 0.813625, 0.725572, 0.779238}}, {0.0825777, 3.24692, -3.59541, 0.265904, 0.0352054, 1.38426, -1.53283, 0.113363, 0.0160695, 0.631846, -0.69966, 0.0517445, 0.0836078, 3.28742, -3.64025, 0.269221, 0.0712929, 2.80321, -3.10407, 0.229567}}, {{3, {0.420694, 0.584352, 0.0468076, 0.102514, 0.520932}, 0.561928, {0.176417, 0.271223, 0.00646194, 0.925226, 0.187549}, {0.262794, 0.430429, 0.037479, 0.20862, 0.565043, 0.873216, 0.684796, 0.491074, 0.998826, 0.0113904, 0.871171, 0.765502, 0.219589, 0.590696, 0.28682, 0.718694, 0.117075, 0.0697643, 0.724892, 0.542277}}, {0.199039, 0.0753504, 0.126656, -0.401045, 0.360411, 0.136441, 0.229344, -0.726196, 0.00501628, 0.00189902, 0.00319207, -0.0101074, 0.759381, 0.28748, 0.483225, -1.53009, 0.233908, 0.0885508, 0.148845, -0.471303}}, {{1, {0.845852, 0.0633023, 0.799666, 0.354728, 0.583058}, 0.632873, {0.762187, 0.146108, 0.0180144, 0.759657, 0.0773905}, {0.655034, 0.019188, 0.748267, 0.206219, 0.889532, 0.799599, 0.157571, 0.919399, 0.170838, 0.682524, 0.0878064, 0.194508, 0.628561, 0.836672, 0.0245041, 0.394842, 0.273833, 0.253614, 0.391631, 0.632656}}, {0.209123, -2.20515, 0.634722, 1.36131, 0.0183297, -0.193283, 0.0556338, 0.11932, 0.00471956, -0.0497668, 0.0143247, 0.0307226, 0.127545, -1.34494, 0.387121, 0.830272, 0.0163267, -0.172161, 0.0495541, 0.10628}}, {{0, {0.127725, 0.2356, 0.631974, 0.555265, 0.472691}, 0.216412, {0.883707, 0.349046, 0.583159, 0.416812, 0.726137}, {0.429647, 0.412321, 0.734288, 0.63833, 0.235139, 0.78376, 0.897616, 0.613826, 0.840297, 0.509927, 0.644002, 0.222195, 0.207641, 0.382201, 0.408402, 0.590221, 0.652376, 0.90951, 0.19199, 0.706514}}, {-0.906056, 0.237992, 0.343764, 0.324299, -0.398638, 0.10471, 0.151246, 0.142682, -0.989979, 0.260036, 0.375605, 0.354337, -0.655338, 0.172137, 0.24864, 0.234561, -1.05119, 0.276115, 0.39883, 0.376246}}, {{0, {0.303331, 0.326351, 0.775178, 0.980377, 0.873684}, 0.91403, {0.0408897, 0.342047, 0.638545, 0.130269, 0.143274}, {0.728221, 0.798248, 0.620343, 0.499272, 0.506026, 0.590606, 0.238141, 0.0908707, 0.915805, 0.93823, 0.328631, 0.898881, 0.209291, 0.6349, 0.00228016, 0.123703, 0.228914, 0.761216, 0.0882505, 0.0828134}}, {-0.130405, 0.00281146, 0.110723, 0.0168702, -1.11625, 0.0240658, 0.947778, 0.144407, -3.2643, 0.0703767, 2.77163, 0.422297, -0.817633, 0.0176278, 0.69423, 0.105776, -0.808253, 0.0174255, 0.686265, 0.104562}}, {{2, {0.886867, 0.122671, 0.957981, 0.939539, 0.158647}, 0.324423, {0.337639, 0.440267, 0.652621, 0.733817, 0.0994976}, {0.349396, 0.736816, 0.795587, 0.770867, 0.450516, 0.527525, 0.160687, 0.768586, 0.326812, 0.298611, 0.399471, 0.680336, 0.243999, 0.411744, 0.2768, 0.722355, 0.30446, 0.253097, 0.952377, 0.384716}}, {0.566563, 0.241362, -0.842934, 0.0350088, 0.344054, 0.146571, -0.511884, 0.0212596, 1.17582, 0.500913, -1.74939, 0.0726557, 1.29795, 0.552942, -1.9311, 0.0802024, 0.0806022, 0.0343374, -0.11992, 0.00498052}}, {{2, {0.864193, 0.600476, 0.218561, 0.285218, 0.514796}, 0.86366, {0.422974, 0.514352, 0.0642807, 0.336135, 0.262287}, {0.745765, 0.737468, 0.0375234, 0.862816, 0.0654296, 0.493469, 0.62578, 0.586016, 0.343075, 0.18901, 0.372683, 0.633638, 0.958359, 0.324817, 0.772206, 0.415078, 0.67314, 0.810021, 0.908547, 0.992103}}, {0.690566, 0.47526, -1.36417, 0.198348, 0.645091, 0.443964, -1.27434, 0.185286, 0.0550272, 0.0378708, -0.108703, 0.0158052, 0.307581, 0.211683, -0.607608, 0.0883449, 0.301945, 0.207804, -0.596475, 0.0867261}}, {{3, {0.158789, 0.74574, 0.572412, 0.729816, 0.413023}, 0.00827203, {0.534889, 0.867, 0.347594, 0.514803, 0.909109}, {0.280984, 0.00451867, 0.325793, 0.536426, 0.647346, 0.0461598, 0.000975324, 0.76422, 0.232268, 0.373019, 0.190954, 0.855673, 0.240165, 0.214231, 0.445214, 0.283261, 0.510349, 0.801207, 0.436942, 0.748373}}, {0.0971915, 0.220711, 0.283169, -0.601071, 0.283331, 0.643413, 0.825489, -1.75223, 0.0955149, 0.216904, 0.278284, -0.590702, 0.165577, 0.376007, 0.482411, -1.02399, 0.213007, 0.483715, 0.620598, -1.31732}}, {{3, {0.643348, 0.453614, 0.922139, 0.839264, 0.362364}, 0.449095, {0.596346, 0.302837, 0.715018, 0.402935, 0.595371}, {0.538617, 0.48275, 0.0299162, 0.404417, 0.682944, 0.242585, 0.815686, 0.959203, 0.399682, 0.732236, 0.0144781, 0.522261, 0.65131, 0.0888876, 0.560864, 0.600122, 0.812046, 0.726524, 0.111769, 0.00377583}}, {0.0735152, 0.112769, 1.4206, -1.60689, 0.0308807, 0.0473698, 0.596735, -0.674986, 0.116486, 0.178685, 2.25096, -2.54613, 0.0604225, 0.0926858, 1.1676, -1.32071, 0.0554161, 0.0850062, 1.07086, -1.21128}}, {{2, {0.509209, 0.0115056, 0.708834, 0.408405, 0.970592}, 0.528756, {0.678917, 0.00398783, 0.287648, 0.286171, 0.863232}, {0.0447847, 0.887966, 0.553935, 0.848754, 0.522523, 0.236656, 0.465048, 0.28789, 0.922401, 0.42461, 0.738524, 0.17612, 0.918625, 0.915401, 0.727018, 0.467287, 0.510221, 0.944809, 0.198262, 0.788369}}, {0.636357, 0.0387519, -0.810828, 0.135719, 0.00227233, 0.000138377, -0.00289533, 0.000484629, 0.329186, 0.0200463, -0.41944, 0.0702071, 0.242511, 0.0147681, -0.309, 0.0517214, 1.28348, 0.0781592, -1.63537, 0.273733}}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float tmpdloga[5];
      float tmpdc[5];
      float tmpdd[5 * 4];
#define logafunc(n) data[i].inputs.loga[n]
#define cfunc(n) data[i].inputs.c[n]
#define dfunc(n, k) data[i].inputs.d[4 * n + k]
      dlogpratingdall (tmpdloga,
                       tmpdc,
                       tmpdd,
                       data[i].inputs.rating,
                       logafunc,
                       5,
                       data[i].inputs.logbeta,
                       cfunc,
                       dfunc,
                       4);
#undef dfunc
#undef cfunc
#undef logafunc

      for (unsigned int j = 0; j < 5 * 4; ++j)
        {
          assert (fabs (tmpdd[j] - data[i].desired_output[j]) <=
                  1e-3 * (1 + fabs (tmpdd[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", tmpdd[j], data[i].desired_output[j]),
                   0));
        }
    }
}

typedef struct _QFuncTestDatum QFuncTestDatum;
struct _QFuncTestDatum
{ 
  struct
    {
      float    loga[6 * 4];
      float    gamma[6];
      float    logbeta[3];
      float    c[6 * 5];
      float    d[6 * 5];
      float    pz[3 * 5];
      float    priorz[5];
      Rating    ratings[8];
      float    logastddev;
      float    gammamean;
      float    gammastddev;
      float    logbetamean;
      float    logbetastddev;
      float    cmean;
      float    cstddev;
      float    dmean;
      float    dstddev;
    }                   inputs;
  float                desired_output;
};

static void
test_qfunc (void)
{
  QFuncTestDatum data[] = 
    {{{{0.124675, 0.981495, 0.994438, 0.0903638, 0.234626, 0.39429,0.236986, 0.707479, 0.157089, 0.0833891, 0.658436, 0.575296,0.584302, 0.413184, 0.900096, 0.65283, 0.313822, 0.586035,0.358478, 0.652303, 0.93129, 0.0675898, 0.15319,0.968307}, {0.806615, 0.0860946, 0.158752, 0.877943, 0.571989,0.691805}, {0.921766, 0.170463, 0.414901}, {0.608416, 0.26333,0.595167, 0.830598, 0.195231, 0.363233, 0.942337, 0.516776,0.609196, 0.00475547, 0.290035, 0.585486, 0.541607, 0.851566,0.321728, 0.778871, 0.455512, 0.692814, 0.443785, 0.206882,0.763707, 0.771048, 0.273322, 0.791981, 0.155292, 0.507718,0.678155, 0.961383, 0.960061, 0.144485}, {0.735818, 0.444608,0.350864, 0.13973, 0.445783, 0.859121, 0.809258, 0.288164,0.124055, 0.0802499, 0.353746, 0.59535, 0.68027, 0.873368,0.590038, 0.824301, 0.406948, 0.0813864, 0.434746, 0.316583,0.728792, 0.120003, 0.474686, 0.172098, 0.992974, 0.675396,0.123821, 0.0323685, 0.547191, 0.816274}, {0.314564, 0.744205,0.423136, 0.736024, 0.960818, 0.148855, 0.742866, 0.862657,0.37078, 0.324554, 0.335918, 0.78127, 0.936033, 0.00797108,0.607126}, {0.661267, 0.461348, 0.835873, 0.614151,0.985871}, {{3, 2, 0}, {1, 2, 4}, {0, 0, 4}, {3, 2, 0}, {3, 2,2}, {2, 0, 0}, {1, 1, 3}, {2, 1, 1}}, 0.337526, 0.803505,0.0669603, 0.169597, 0.0229627, 0.0592998, 0.643824, 0.433573,0.0621448}, -1086.96}, {{{0.910444, 0.900958, 0.570916, 0.691365,0.58589, 0.56504, 0.789646, 0.755332, 0.577919, 0.957914,0.128379, 0.293984, 0.742046, 0.343763, 0.142508, 0.956458,0.938542, 0.276803, 0.97291, 0.933495, 0.879242, 0.632978,0.539338, 0.871351}, {0.968797, 0.73202, 0.968422, 0.179985,0.382907, 0.16698}, {0.178775, 0.424654, 0.804988}, {0.209065,0.0503965, 0.130669, 0.0629414, 0.865303, 0.907889, 0.174211,0.1244, 0.5885, 0.934978, 0.240716, 0.245158, 0.955522, 0.395641,0.369366, 0.276361, 0.223502, 0.427219, 0.18938, 0.893454,0.0565226, 0.248444, 0.764727, 0.0884662, 0.847457, 0.198047,0.634057, 0.0255248, 0.982154, 0.290158}, {0.459846, 0.901125,0.393654, 0.35518, 0.21913, 0.655967, 0.438132, 0.959539,0.849764, 0.379606, 0.21463, 0.53232, 0.660383, 0.486152,0.158107, 0.283877, 0.895657, 0.397686, 0.31065, 0.0858294,0.2616, 0.372161, 0.328496, 0.795671, 0.801754, 0.471036,0.934842, 0.440491, 0.582624, 0.815069}, {0.496709, 0.480952,0.73286, 0.435463, 0.282079, 0.948632, 0.0724769, 0.949311,0.123972, 0.664755, 0.17682, 0.551625, 0.813322, 0.578926,0.915221}, {0.179464, 0.484826, 0.783255, 0.113467,0.708428}, {{1, 1, 3}, {1, 2, 2}, {3, 0, 4}, {1, 0, 4}, {2, 2,4}, {2, 1, 2}, {1, 0, 1}, {2, 2, 2}}, 0.549984, 0.342764,0.530843, 0.893358, 0.0532749, 0.861812, 0.797982, 0.457895,0.771195}, -263.058}, {{{0.91318, 0.725505, 0.508584, 0.647223,0.248425, 0.548685, 0.956959, 0.833902, 0.669499, 0.633465,0.777495, 0.349076, 0.886244, 0.519998, 0.0690674, 0.799091,0.54348, 0.989155, 0.175709, 0.745816, 0.681668, 0.191173,0.717814, 0.974621}, {0.768488, 0.465668, 0.20923, 0.327398,0.520064, 0.916982}, {0.252271, 0.493496, 0.850565}, {0.283518,0.474775, 0.14442, 0.964321, 0.76352, 0.405708, 0.345329,0.420841, 0.774365, 0.229999, 0.599513, 0.739173, 0.583192,0.512185, 0.624892, 0.970685, 0.117524, 0.302956, 0.297494,0.450621, 0.200542, 0.050685, 0.803998, 0.600056, 0.917024,0.57591, 0.659578, 0.635734, 0.153504, 0.170202}, {0.314249,0.214893, 0.37914, 0.940203, 0.714736, 0.47572, 0.795948,0.428017, 0.0898439, 0.505035, 0.678424, 0.125062, 0.79235,0.0544142, 0.477882, 0.0743769, 0.988351, 0.454358, 0.560858,0.498467, 0.328774, 0.818624, 0.407353, 0.328266, 0.0145251,0.603731, 0.0282136, 0.388063, 0.299789, 0.128011}, {0.232266,0.960046, 0.209946, 0.622976, 0.553842, 0.834984, 0.417596,0.568561, 0.0759604, 0.760607, 0.429245, 0.114203, 0.515103,0.26214, 0.100471}, {0.295579, 0.10775, 0.933874, 0.0859458,0.691849}, {{0, 1, 0}, {1, 1, 0}, {0, 0, 3}, {0, 1, 2}, {3, 2,2}, {0, 2, 4}, {0, 2, 1}, {2, 0, 2}}, 0.079536, 0.545811,0.786156, 0.563838, 0.84727, 0.585765, 0.576211, 0.940862,0.293428}, -270.86}, {{{0.750781, 0.158615, 0.372301, 0.217468,0.990174, 0.72937, 0.258098, 0.702365, 0.728034, 0.6289, 0.962518,
0.594615, 0.79416, 0.542954, 0.27067, 0.515079, 0.24835,0.756797, 0.706832, 0.667809, 0.662585, 0.180586, 0.76597,0.374381}, {0.911804, 0.0219714, 0.393669, 0.156913, 0.92163,0.292601}, {0.135571, 0.454548, 0.193596}, {0.663701, 0.173053,0.859933, 0.399436, 0.120748, 0.902383, 0.344854, 0.151086,0.36395, 0.195551, 0.677045, 0.488501, 0.183364, 0.429581,0.302664, 0.576697, 0.161393, 0.0359121, 0.145751, 0.655067,0.868792, 0.900341, 0.691203, 0.461471, 0.20509, 0.727288,0.83127, 0.0620353, 0.0843424, 0.824906}, {0.486416, 0.910949,0.720392, 0.629355, 0.809371, 0.422448, 0.537028, 0.199774,0.506707, 0.845752, 0.375635, 0.163862, 0.360956, 0.190685,0.506844, 0.263521, 0.669753, 0.729214, 0.301753, 0.536233,0.838483, 0.667179, 0.217411, 0.711327, 0.352068, 0.756229,0.497019, 0.0819719, 0.542697, 0.333781}, {0.959991, 0.882198,0.0359907, 0.488029, 0.584356, 0.718336, 0.675035, 0.297344,0.0775124, 0.454815, 0.00528215, 0.56813, 0.775759, 0.918582,0.166799}, {0.900952, 0.558348, 0.207255, 0.814731,0.144722}, {{0, 2, 0}, {3, 2, 1}, {0, 0, 0}, {2, 2, 1}, {2, 1,4}, {1, 1, 0}, {2, 0, 3}, {2, 2, 3}}, 0.0613287, 0.125283,0.272034, 0.810942, 0.101338, 0.243086, 0.236043, 0.322913,0.516982}, -519.025}, {{{0.52475, 0.561008, 0.0255681, 0.439469,0.0699348, 0.555726, 0.457438, 0.66371, 0.151352, 0.388927,0.556486, 0.105362, 0.944097, 0.574196, 0.411763, 0.0440337,0.818814, 0.302162, 0.600822, 0.942696, 0.575728, 0.0661194,0.277909, 0.425715}, {0.0509784, 0.505111, 0.252341, 0.986245,0.981044, 0.949386}, {0.794903, 0.322535, 0.829691}, {0.560459,0.238417, 0.217173, 0.885594, 0.986262, 0.826654, 0.173139,0.0667804, 0.6841, 0.225832, 0.230443, 0.491052, 0.617981,0.947923, 0.804728, 0.440074, 0.112869, 0.695582, 0.818483,0.45903, 0.163483, 0.900678, 0.495948, 0.629339, 0.603025,0.662261, 0.278775, 0.743745, 0.616762, 0.835607}, {0.105636,0.676965, 0.932662, 0.609775, 0.875193, 0.185913, 0.314682,0.661852, 0.0704646, 0.745839, 0.201813, 0.96627, 0.251982,0.286808, 0.0383293, 0.0655914, 0.756034, 0.657469, 0.435305,0.403331, 0.47726, 0.913724, 0.818542, 0.567724, 0.371624,0.236759, 0.88588, 0.957949, 0.496431, 0.050846}, {0.571198,0.296097, 0.425967, 0.305007, 0.369385, 0.329828, 0.173985,0.0181991, 0.331056, 0.264236, 0.41795, 0.36073, 0.895751,0.860906, 0.940691}, {0.447007, 0.0772093, 0.293182, 0.569067,0.210248}, {{3, 1, 0}, {2, 0, 2}, {0, 2, 4}, {3, 0, 4}, {2, 2,2}, {3, 1, 4}, {2, 1, 4}, {3, 1, 1}}, 0.19133, 0.335233,0.072636, 0.159402, 0.620132, 0.0391354, 0.64667, 0.854395,0.250746}, -341.876}, {{{0.709308, 0.472685, 0.836196, 0.91969,0.445072, 0.0547344, 0.475465, 0.023939, 0.584166, 0.114043,0.0284586, 0.94673, 0.290984, 0.544976, 0.818211, 0.7554,0.955751, 0.47234, 0.658808, 0.135269, 0.916616, 0.825671,0.804414, 0.884522}, {0.207308, 0.352986, 0.968218, 0.964832,0.762237, 0.298252}, {0.492753, 0.940893, 0.178071}, {0.184208,0.464294, 0.994163, 0.887087, 0.639232, 0.646084, 0.238763,0.931336, 0.166891, 0.987275, 0.103494, 0.0147198, 0.341221,0.182861, 0.218972, 0.807412, 0.988234, 0.214643, 0.25414,0.0451752, 0.689983, 0.72189, 0.313247, 0.867105, 0.505775,0.257596, 0.319084, 0.980018, 0.866543, 0.611513}, {0.080321,0.0486824, 0.699651, 0.624237, 0.976827, 0.0339626, 0.358431,0.441376, 0.757855, 0.226551, 0.370196, 0.226733, 0.503715,0.181376, 0.680213, 0.504842, 0.190468, 0.314271, 0.174439,0.247246, 0.871384, 0.334253, 0.307896, 0.635733, 0.791063,0.285571, 0.608245, 0.0114959, 0.814236, 0.251608}, {0.249814,0.57012, 0.0563813, 0.0250572, 0.879618, 0.343387, 0.552666,0.843682, 0.199405, 0.838545, 0.362198, 0.52941, 0.0249658,0.591299, 0.490815}, {0.195157, 0.71707, 0.955565, 0.699752,0.909587}, {{3, 1, 1}, {0, 1, 4}, {0, 1, 1}, {3, 1, 1}, {1, 0,0}, {1, 0, 4}, {1, 2, 0}, {0, 0, 4}}, 0.108825, 0.94407,0.885515, 0.657978, 0.85901, 0.37395, 0.829134, 0.632921,0.979392}, -227.112}, {{{0.0305625, 0.276468, 0.78924, 0.779988,0.192018, 0.914269, 0.259829, 0.755022, 0.600719, 0.423455,0.0646719, 0.0379523, 0.645153, 0.723703, 0.155085, 0.929128,0.701084, 0.838188, 0.497107, 0.0701171, 0.327134, 0.00905376,0.864186, 0.0907247}, {0.296572, 0.732586, 0.074946, 0.310737,0.104554, 0.818317}, {0.815117, 0.555715, 0.503835}, {0.394862,0.750445, 0.517763, 0.858682, 0.671159, 0.59536, 0.588635,0.157598, 0.832971, 0.0982528, 0.518518, 0.830464, 0.823917,0.234067, 0.427793, 0.533892, 0.0913312, 0.159121, 0.117056,0.429338, 0.273014, 0.344004, 0.561341, 0.925503, 0.878152,0.593559, 0.0435786, 0.0668205, 0.206994, 0.9982}, {0.454944,0.909222, 0.374023, 0.899947, 0.936426, 0.0787583, 0.550105,0.66588, 0.508632, 0.544866, 0.458774, 0.506758, 0.391576,0.115528, 0.18576, 0.162754, 0.830235, 0.190025, 0.307607,0.569195, 0.786656, 0.123205, 0.100614, 0.570995, 0.331712,0.213983, 0.726591, 0.671049, 0.395287, 0.135224}, {0.176486,0.00516912, 0.886655, 0.590358, 0.717711, 0.498411, 0.495079,0.47483, 0.531952, 0.335657, 0.664844, 0.284805, 0.224344,0.766462, 0.878188}, {0.1616, 0.12373, 0.195466, 0.546476,0.947617}, {{3, 1, 4}, {0, 2, 3}, {1, 0, 2}, {2, 1, 4}, {1, 2,2}, {3, 2, 3}, {2, 2, 4}, {2, 2, 4}}, 0.397139, 0.524418,0.151189, 0.812393, 0.220653, 0.519249, 0.264535, 0.222035,0.502942}, -103.632}, {{{0.0208379, 0.769456, 0.747204, 0.97099,0.685181, 0.104612, 0.4624, 0.746646, 0.91872, 0.226423, 0.3008,0.622916, 0.723253, 0.679947, 0.353183, 0.225777, 0.198835,0.528758, 0.54079, 0.00512376, 0.679587, 0.264224, 0.318755,0.502182}, {0.658749, 0.494768, 0.571551, 0.531192, 0.973568,0.390156}, {0.109151, 0.784546, 0.054848}, {0.163733, 0.808351,0.16163, 0.331595, 0.483786, 0.455169, 0.935853, 0.132759,0.955027, 0.914379, 0.930729, 0.453173, 0.690803, 0.595624,0.428547, 0.794424, 0.196036, 0.0240728, 0.897355, 0.820856,0.805879, 0.914922, 0.112809, 0.766008, 0.642146, 0.10657,0.95118, 0.434413, 0.158361, 0.651401}, {0.0153266, 0.301654,0.203334, 0.737022, 0.0845975, 0.848481, 0.51253, 0.141399,0.65605, 0.0540575, 0.316495, 0.117326, 0.758695, 0.233201,0.510615, 0.202404, 0.645886, 0.467193, 0.868469, 0.0958342,0.694706, 0.0327795, 0.710108, 0.444433, 0.679379, 0.731125,0.506775, 0.707411, 0.594782, 0.882644}, {0.994245, 0.566012,0.938732, 0.828587, 0.67775, 0.448686, 0.180037, 0.595385,0.167135, 0.246282, 0.534151, 0.128192, 0.298666, 0.150448,0.839445}, {0.0954129, 0.588558, 0.706015, 0.160066,0.364287}, {{1, 1, 4}, {3, 0, 1}, {1, 0, 0}, {0, 2, 0}, {0, 1,4}, {0, 2, 3}, {0, 1, 2}, {2, 2, 4}}, 0.0817831, 0.998604,0.565284, 0.481643, 0.0875386, 0.432592, 0.626552, 0.653057,0.409789}, -313.47}, {{{0.983906, 0.446516, 0.0576713, 0.242654,0.737624, 0.912365, 0.929479, 0.943988, 0.587176, 0.0729197,0.834066, 0.35543, 0.881161, 0.912854, 0.469778, 0.273647,0.882556, 0.34757, 0.988135, 0.186109, 0.449964, 0.721018,0.335079, 0.77632}, {0.466058, 0.274503, 0.277407, 0.533666,0.728435, 0.362138}, {0.347928, 0.589678, 0.141259}, {0.289218,0.513862, 0.234248, 0.260099, 0.376364, 0.0440839, 0.960601,0.377542, 0.0287939, 0.0559487, 0.774492, 0.927578, 0.307776,0.72087, 0.998172, 0.46152, 0.0332729, 0.443463, 0.464505,0.733085, 0.671135, 0.0955347, 0.874827, 0.591826, 0.381916,0.581672, 0.640579, 0.331727, 0.00555209, 0.537588}, {0.679978,0.954184, 0.976758, 0.48164, 0.905487, 0.0266062, 0.668983,0.760769, 0.907315, 0.565086, 0.63571, 0.317306, 0.44281,0.832001, 0.964575, 0.221772, 0.567983, 0.240176, 0.582658,0.640099, 0.927404, 0.908449, 0.577106, 0.102511, 0.247425,0.954265, 0.600348, 0.620871, 0.341939, 0.927658}, {0.931366,0.860102, 0.434624, 0.362572, 0.295656, 0.542796, 0.991814,0.530571, 0.331081, 0.321024, 0.423832, 0.290395, 0.748423,0.680925, 0.496428}, {0.381946, 0.171317, 0.578414, 0.249002,0.427681}, {{1, 1, 0}, {2, 2, 3}, {1, 1, 1}, {0, 0, 1}, {2, 2,4}, {2, 0, 4}, {3, 0, 3}, {3, 2, 1}}, 0.570968, 0.957542,0.907064, 0.500023, 0.639603, 0.0974402, 0.47244, 0.137451,0.343947}, -150.223}, {{{0.554644, 0.480625, 0.60688, 0.0128657,0.23362, 0.056794, 0.316485, 0.264443, 0.552695, 0.560366,0.93454, 0.0931264, 0.974282, 0.311364, 0.506859, 0.522158,0.0167393, 0.4043, 0.00683598, 0.882555, 0.919299, 0.93186,0.869385, 0.538608}, {0.364655, 0.451235, 0.262505, 0.525743,0.131035, 0.394441}, {0.94602, 0.2613, 0.578339}, {0.834075,0.01148, 0.168173, 0.604058, 0.522711, 0.504621, 0.646015,0.587318, 0.118411, 0.497785, 0.76346, 0.668019, 0.18655, 0.6284,0.224852, 0.303365, 0.735316, 0.365895, 0.699109, 0.17233,0.340875, 0.419875, 0.43781, 0.593991, 0.5068, 0.408395, 0.269636,
0.989933, 0.984089, 0.903774}, {0.623621, 0.402615, 0.865678,0.405988, 0.860161, 0.734595, 0.679127, 0.777588, 0.635309,0.431231, 0.943812, 0.411694, 0.936199, 0.258901, 0.602937,0.991818, 0.49839, 0.66491, 0.0961375, 0.583423, 0.228753,0.674977, 0.112049, 0.67965, 0.605132, 0.272362, 0.246371,0.273661, 0.744971, 0.537767}, {0.567243, 0.496073, 0.109663,0.106536, 0.623432, 0.0843793, 0.173463, 0.847636, 0.0204943,0.0925609, 0.675074, 0.182725, 0.924357, 0.509138,0.446321}, {0.507748, 0.812308, 0.829488, 0.841188,0.235386}, {{3, 1, 4}, {2, 2, 0}, {2, 1, 2}, {2, 1, 2}, {3, 0,3}, {0, 0, 2}, {1, 1, 3}, {2, 2, 2}}, 0.565937, 0.555827,0.0962168, 0.697619, 0.998694, 0.059754, 0.986554, 0.591083,0.375262}, -118.913}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      ParameterizedNormalDistribution prior_loga = 
        parameterized_normal_distribution (data[i].inputs.logastddev);
      NormalDistribution prior_gamma = 
        normal_distribution (data[i].inputs.gammamean,
                             data[i].inputs.gammastddev);
      NormalDistribution prior_logbeta = 
        normal_distribution (data[i].inputs.logbetamean, 
                             data[i].inputs.logbetastddev);
      NormalDistribution prior_c = 
        normal_distribution (data[i].inputs.cmean, 
                             data[i].inputs.cstddev);
      NormalDistribution prior_d = 
        normal_distribution (data[i].inputs.dmean, 
                             data[i].inputs.dstddev);

      float hq = 0;

      for (unsigned int j = 0; j < 3 * 5; ++j)
        {
          hq -= data[i].inputs.pz[j] * log (data[i].inputs.pz[j]);
        }

      float output = qfunc (data[i].inputs.loga,
                             4,
                             6,
                             data[i].inputs.gamma,
                             data[i].inputs.logbeta,
                             3,
                             data[i].inputs.c,
                             5,
                             data[i].inputs.d,
                             data[i].inputs.pz,
                             data[i].inputs.ratings,
                             8,
                             &prior_loga.base,
                             &prior_gamma.base,
                             &prior_logbeta.base,
                             &prior_c.base,
                             &prior_d.base,
                             hq);

      assert (fabs (output - data[i].desired_output) <=
              1e-3 * (1 + fabs (output) + fabs (data[i].desired_output)) ||
              (fprintf (stderr, "%g ?= %g\n", output, data[i].desired_output),
               0));
    }
}

typedef struct _DQFuncDLogATestDatum DQFuncDLogATestDatum;
struct _DQFuncDLogATestDatum 
{
  struct
    {
      float    loga[6 * 4];
      float    gamma[6];
      float    logbeta[3];
      float    c[6 * 5];
      float    d[6 * 5];
      float    pz[3 * 5];
      float    priorz[5];
      Rating    ratings[8];
      float    logastddev;
      float    gammamean;
      float    gammastddev;
      float    logbetamean;
      float    logbetastddev;
      float    cmean;
      float    cstddev;
      float    dmean;
      float    dstddev;
    }                   inputs;
  float                desired_output[6 * 4];
};

static void
test_dqfuncdloga (void)
{
  DQFuncDLogATestDatum data[] = 

   {{{{0.1511609342966948, 0.8129527354596378, 0.45497385215067065, 0.012520239700434718, 0.04257951509056202, 0.3472073158929671, 0.011119782953456524, 0.0669010334071294, 0.6358867999197769, 0.41350822114853425, 0.30311339900013873, 0.41666619854135006, 0.7425752533164133, 0.2025221971225223, 0.6635692343114998, 0.07752666467268429, 0.13725492973916562, 0.43656489769724477, 0.7029179124632411, 0.9460419048763731, 0.25626440077221296, 0.8687885984829148, 0.14938262385754222, 0.20723055433994197}, {0.10510346647551816, 0.055835863023277026, 0.6944087717068715, 0.19471031463950725, 0.06252395138495613, 0.7086285471303099}, {0.683288988753415, 0.12780928123237784, 0.4266371514651792}, {0.2951203259817757, 0.3801755897532763, 0.7111430826910278, 0.684061898148766, 0.09259812885925335, 0.7166063554417765, 0.6336164180183435, 0.5468069684096003, 0.6560332311620086, 0.013688442978535434, 0.6875745131419704, 0.29054256763738734, 0.7872446326790938, 0.8643058191209932, 0.4803439588020284, 0.18543910116186918, 0.7314087696558168, 0.16989704741412162, 0.2856336441625212, 0.12291514977691306, 0.022780222525506842, 0.48660805866070656, 0.15782436293014332, 0.6962779983117339, 0.7276598965437312, 0.10643246890743023, 0.4466812802391155, 0.012216100162967898, 0.6350617676844779, 0.3898261134656537}, {0.813064862220772, 0.4654091317533676, 0.9790285365224692, 0.37613767048711827, 0.12549034907880163, 0.17486656411598026, 0.19178390384337543, 0.5118318513661251, 0.6451463902767732, 0.9894274629541111, 0.46037513418755865, 0.34193480395200343, 0.35951274611425205, 0.866512313177198, 0.43759491166205183, 0.8553267452912969, 0.20168838318410873, 0.17023431486546417, 0.7099350151183207, 0.7488942763838666, 0.7550071029449932, 0.15801821470249627, 0.07487324743384285, 0.359068162918213, 0.9419422407242212, 0.6926090829491287, 0.09584471091137362, 0.9829304924310946, 0.8164518916454195, 0.5177425188331485}, {0.9040608070679982, 0.4710986410649696, 0.1713055013686463, 0.5283150558790374, 0.44368567288043953, 0.1291638371129662, 0.8117927552543942, 0.6618027427018394, 0.006090761218387678, 0.2738370918216693, 0.6101043720702856, 0.49156842783637517, 0.296155746100067, 0.5249428154378026, 0.8550972691252923}, {0.3335502131338789, 0.22128249866622415, 0.16587465251958966, 0.9131550284010711, 0.6409411301847502}, {{2, 0, 0}, {2, 2, 3}, {0, 1, 0}, {1, 2, 1}, {2, 0, 4}, {1, 1, 4}, {1, 1, 0}, {1, 2, 3}}, 0.12543778775485054, 0.18294416008849498, 0.09670313675565159, 0.12319861135160179, 0.22137698068685235, 0.7118455190235253, 0.9253976353870053, 0.5948835554725644, 0.7776913078064128}, {-3.6065780439134056, -48.225112975394104, 14.756538872318517, 10.958836732058986, 0.7334111482175806, 22.57981374992404, 4.829779996283544, -2.631618242570367, -0.7246806271021653, -16.592235768061336, -17.304367204860366, 17.086056011257728, -43.5263042794177, -13.649377481311552, -4.006747964445297, 4.708534958727999, -8.078424185071658, 13.930942771260273, -37.99353444602699, -56.57620488061396, 27.84587450232997, -42.84043012568823, -5.52024427383657, 31.86584452160819}},{{{0.5826816819105591, 0.11360488013261104, 0.9330808127707251, 0.7716005465880251, 0.30884459008888987, 0.5035005080623255, 0.44151238493434986, 0.4754448004879582, 0.7839017746510872, 0.6484032389370332, 0.10796217180047096, 0.254162301821734, 0.6180271221314976, 0.7352482105359621, 0.4670210416157207, 0.12872451406688346, 0.43508296204300256, 0.6385450737803104, 0.34382243026411896, 0.907347533380031, 0.7232374430194772, 0.7131474383933052, 0.7489388747915545, 0.12965622557361825}, {0.14055576110891807, 0.5995425582606941, 0.8158580620208296, 0.35805567898559304, 0.8317111710200282, 0.09604205019836863}, {0.37434567708647964, 0.8826108784976349, 0.04780939636894097}, {0.4476388112613354, 0.2663835052860087, 0.6284485766759009, 0.4297822742374434, 0.7123906007253733, 0.799362463670288, 0.49972406260901747, 0.9946993121944409, 0.07384552694506286, 0.455540033406169, 0.5923765292289863, 0.2714618691749636, 0.36069808855175767, 0.7066011586146145, 0.4627203036553681, 0.13090610806604552, 0.7611555302910635, 0.8907430965937849, 0.10466462466977505, 0.2991949370460173, 0.6651134800926949, 0.5163974195073053, 0.22205374617214016, 0.25138554067707636, 0.21747466883135944, 0.2500139142212966, 0.5936051694962393, 0.8216032664396329, 0.5050840681059862, 0.45065145055100864}, {0.09388110688722182, 0.8269039542451921, 0.43123854116092325, 0.9951114171448396, 0.5015045776582354, 0.5554420850702285, 0.07054045260916558, 0.2885102585302252, 0.03878427400286734, 0.424535977004183, 0.3093849223181021, 0.3977671619364403, 0.9341196493330923, 0.12534103995816565, 0.6442714422254072, 0.881369742429135, 0.7120659031609521, 0.8739554992810893, 0.42679677339404776, 0.6313558282078384, 0.11846073366471285, 0.052352232841456375, 0.9217127052880617, 0.18070437765682973, 0.02457962677749104, 0.22544827859626426, 0.4904741641271384, 0.18559296051199006, 0.5230750491192556, 0.6700061935260357}, {0.4199337115179728, 0.8970827019817649, 0.48429077511638824, 0.24547021652185277, 0.11054878919987074, 0.4993155400453245, 0.550171125783296, 0.12012917656368713, 0.46627734697446355, 0.6179457976161895, 0.8381052226223439, 0.2461736772825978, 0.03948057358041577, 0.9865899694083511, 0.719644488957631}, {0.19382144444114144, 0.11776786829235411, 0.8058855917515214, 0.69506486218014, 0.9683731658448772}, {{3, 0, 1}, {2, 2, 2}, {1, 2, 2}, {0, 0, 1}, {2, 0, 4}, {3, 1, 1}, {3, 1, 1}, {2, 2, 3}}, 0.6272937041652157, 0.6202926312395314, 0.17198981306088437, 0.2983669723188414, 0.2073599926472429, 0.7232099292577665, 0.6876990379444962, 0.052896755796988625, 0.09681120344737217}, {-2.4068514255693474, 1.1822052566195784, -1.0810891228514388, -2.045125408832173, 1.3207325652039053, -1.7004551531096124, -1.2566383026886208, -0.1129149351072537, -2.744347502592179, -1.5110295266095923, 0.7559231265813066, -0.45583244184711963, -4.096220970673561, -2.2961792683891122, -1.9962720788747217, -1.0156681742028295, -0.5895804721886503, -3.784986354480481, -6.571677294349486, -1.531866650537522, -3.942689863098411, -4.5222708955352005, -0.06623393098335367, -2.4009103781743173}},{{{0.22389438921244198, 0.13752791216120017, 0.9327675792333014, 0.6305338564729086, 0.6059485915962525, 0.2994226895388563, 0.6865939019507037, 0.5910532828924928, 0.6193586221879013, 0.5797782005812253, 0.4927724575095622, 0.47328541460013873, 0.81347303043638, 0.8847133384010853, 0.524399291664685, 0.845991710434923, 0.1931803991968486, 0.712723525340201, 0.22603231934584364, 0.6386317177876801, 0.4699704699390821, 0.0250244873957049, 0.17313556354885504, 0.541820514340308}, {0.2460760807266401, 0.8874965752345048, 0.24036798431555353, 0.9112866578673994, 0.6401274891303876, 0.5880738856956484}, {0.5537740823648498, 0.3202333749749065, 0.020768866942486346}, {0.008295685114423086, 0.061001624855287616, 0.8469479603747677, 0.20729583650610642, 0.1235823467133377, 0.5366023331906026, 0.0009562499398446883, 0.014115437309257815, 0.4108588213731367, 0.3105700138447589, 0.36232453215216454, 0.5441449673701757, 0.3858343339774318, 0.13743445029590387, 0.8205040178118566, 0.2980688866435356, 0.498337758742927, 0.8970664659803503, 0.9092173599444572, 0.657941397513148, 0.9102638730472786, 0.3432923836155005, 0.5889839849695507, 0.6371725305706616, 0.9019681879328555, 0.28229075876021287, 0.742036024594783, 0.42987669406455514, 0.7783858412195178, 0.7456884255696103}, {0.7410797746549384, 0.41576125675529735, 0.36752701984638114, 0.43511841172485144, 0.37875524250277376, 0.8716162893851216, 0.9816926858689494, 0.29768396142894754, 0.5582512246909173, 0.573547402741586, 0.48335492712602235, 0.4006174954485972, 0.64903386474646, 0.915606005228438, 0.5730910540787437, 0.05732511183309668, 0.060049879776909273, 0.2784334746577765, 0.6711228661458882, 0.7750343530728838, 0.31801385518212627, 0.8485567805932214, 0.8927370249263704, 0.02934592750327345, 0.576934080527188, 0.432795523837924, 0.5252100050799892, 0.594227515778422, 0.19817883802441422, 0.5611792344528024}, {0.5435173192110399, 0.2965435543494745, 0.639927613333497, 0.9876318317112164, 0.06016239208501748, 0.8959260589008773, 0.990893748587037, 0.07202582648277825, 0.4870713380062738, 0.8386009470677807, 0.9308438688101277, 0.7935923518250018, 0.8159484718603855, 0.06356659399489682, 0.6128300136280015}, {0.9450355712317804, 0.9232114469340152, 0.03422066649162338, 0.03589593310081348, 0.5122400473938563}, {{0, 2, 2}, {1, 1, 1}, {0, 1, 4}, {0, 1, 3}, {2, 2, 4}, {2, 2, 2}, {0, 2, 0}, {0, 2, 4}}, 0.398001441854026, 0.43999315071320133, 0.8377170950763992, 0.9510608129410539, 0.8544841226429861, 0.14344959636372687, 0.19778948174290226, 0.9634289812298377, 0.7943217305579687}, {-0.8785379994704224, 3.2592916670282195, -13.850992247170783, -4.891549183742385, -5.630960616251731, -1.9348860006506097, -3.0295928584658895, -0.24767050082053021, -3.1282470743867674, 2.1007314075786363, -2.4799028937864667, -0.48291242867060485, -3.961386147875343, -0.7761064116225862, -3.491156412083605, -2.3958569851521423, 0.3405546881982593, -3.1779091835781883, 0.1265368014576029, 1.5710636858704086, -1.4494605698885683, 5.594907555945179, 2.9480827855549876, 0.2919910518187446}},{{{0.24752353746284958, 0.20689573315586524, 0.8914031547470593, 0.30725039255169495, 0.40892259039506895, 0.27605186434573753, 0.09781080292205764, 0.49130192069130935, 0.3453559964001721, 0.6632218507177361, 0.15277523169027726, 0.5680904737572942, 0.31113532990854875, 0.6273259176169226, 0.6405351842964209, 0.17008903190326816, 0.8711421791953474, 0.7896088225405233, 0.6894743713553669, 0.315604909260282, 0.7276925828316205, 0.5918193407976211, 0.7260453901255293, 0.5212831787023133}, {0.480169045368771, 0.3849236076417558, 0.8346422353784699, 0.21403278615061838, 0.071246454973702, 0.1088717432960183}, {0.7368314324564122, 0.722730865459309, 0.7258904585735299}, {0.44564989257828225, 0.5840562007661351, 0.15464039170201485, 0.4147551286649811, 0.8183239749613597, 0.9435210164697141, 0.9845513597987466, 0.5436129494696337, 0.028715152420836373, 0.2540466451143472, 0.6689464505384647, 0.8159203666380132, 0.43689581162321534, 0.5280012549888179, 0.14766327183615138, 0.3357513212692422, 0.05197220398145951, 0.693359019610348, 0.933630485685533, 0.2645048662955402, 0.9431004606854412, 0.9565275871539356, 0.210899620226224, 0.5386144077220103, 0.49745056810715893, 0.3724713863878006, 0.05625922852420916, 0.12385927905702926, 0.6791265931457993, 0.42895036991808644}, {0.07170786872546248, 0.5802463295873955, 0.6504114407249629, 0.17490372480373928, 0.4027614181869978, 0.7643259629493824, 0.21351562910174757, 0.6469024698149214, 0.2550981463508464, 0.42857464168014026, 0.16154342512028808, 0.9535434502045734, 0.3214676606653134, 0.16406977538460002, 0.21844296443484687, 0.9970158630506378, 0.11056804043908937, 0.6254553676625897, 0.7209923963276879, 0.6245444766628373, 0.05430881191488021, 0.5015960886055604, 0.041865803181888636, 0.19559410674475078, 0.9826009431894177, 0.9213497590181648, 0.3914543624569257, 0.020690381941011513, 0.57983952500242, 0.15702379606878242}, {0.17793873335517815, 0.37378791212609014, 0.32474137865157354, 0.7284491543886422, 0.016395308234890094, 0.42024446192151665, 0.003273717986260187, 0.5643793790040421, 0.7979523438000432, 0.4232285988708788, 0.8927056775471708, 0.9389240113414524, 0.07695994747235532, 0.7986841222080415, 0.8383968656322907}, {0.43732792273589205, 0.03509414429046669, 0.6030900154632908, 0.8557959224428728, 0.5159781637177272}, {{2, 2, 4}, {3, 0, 2}, {2, 0, 2}, {2, 1, 2}, {2, 2, 4}, {3, 2, 1}, {0, 1, 0}, {2, 1, 4}}, 0.643639781833541, 0.5823996335222792, 0.2759563974404529, 0.3589543676489448, 0.4657010484783628, 0.20861172139618914, 0.9512150187888794, 0.6305052132603026, 0.4493057402434727}, {0.5271846798948561, -0.3276118446396725, -0.5858041229335995, -3.4711838430345914, -0.8628675540125336, -2.292946415012629, 0.9229638730364629, -0.25678382565978963, 1.1810743570935607, -1.084285278432472, -0.19679947429386735, -1.10849410444328, -5.379038239437745, -9.941986893111205, -4.973763863292558, -7.356846925761498, -27.678411916891406, -3.18201195719075, -5.369217803874139, -1.3151299915894676, -5.496138012425586, -3.025544947375691, -5.24307427395233, -2.6023917240390735}},{{{0.7883672594746725, 0.9479413008026192, 0.06612583425626045, 0.6513533964434295, 0.3651386606037937, 0.05523562325544835, 0.12720182291480797, 0.5743934489710741, 0.5664545383957521, 0.21683875762315774, 0.6898739001789159, 0.5392993046806075, 0.9633645229324613, 0.36104283518028485, 0.17389573646118872, 0.8956595228470665, 0.38096488941018214, 0.08508643773983196, 0.814941368812244, 0.4299584743687037, 0.172353168013993, 0.13387141895095261, 0.18443615555194134, 0.980652734125231}, {0.3839859085393205, 0.18593011814833343, 0.11831032129568089, 0.32929933768180153, 0.018847247935526827, 0.1306944948928851}, {0.9911084983808729, 0.7549058887107274, 0.4523927095397747}, {0.9138557372697274, 0.30123459820195697, 0.21560658403011995, 0.4890281866073133, 0.5528129020894424, 0.12733886174076825, 0.31994706118305344, 0.10806329719713118, 0.4677264643496105, 0.3123974929285243, 0.8899885868143498, 0.9357101291831382, 0.3338550453986579, 0.12796133737658297, 0.9093358526891188, 0.5517242206438177, 0.1479249272503245, 0.009651016080902085, 0.5800365150073172, 0.5328769727082908, 0.017230432357439388, 0.01854251770002917, 0.8251306262965898, 0.08048426316851615, 0.10337469508771203, 0.7173079194980722, 0.6095240422664698, 0.5914560765612028, 0.5505617929982696, 0.5899690577573039}, {0.2895769810834164, 0.48339277936407166, 0.08283532864865902, 0.2775715648287796, 0.39958839426906667, 0.5476826501809334, 0.7489802832500011, 0.14961022745219663, 0.4902525415799479, 0.9959584295371158, 0.6010553559996766, 0.13995921137129455, 0.9102160265726307, 0.46308145682882496, 0.5838249236422373, 0.12141669367126537, 0.08508540027604092, 0.3825971936603088, 0.4804502285545252, 0.4041087741731932, 0.47556135800957106, 0.791141117099106, 0.9298884355562557, 0.8141397164158892, 0.18598437692615463, 0.30774833773503435, 0.8470531069075966, 0.5365681515871097, 0.786395982657088, 0.7600656875541009}, {0.09807282365759554, 0.38695792413491303, 0.29614344107714, 0.7641072580169851, 0.49701746765791893, 0.24699871276361848, 0.38592741450450935, 0.3010258011881601, 0.9131925440156817, 0.12558201909235311, 0.3008420142284684, 0.9184286075278513, 0.43274231546115655, 0.72147324491916, 0.8252806562188973}, {0.12728749042874524, 0.5028538799049008, 0.9073335285032706, 0.6392962792927427, 0.8195391526937109}, {{3, 2, 3}, {3, 0, 0}, {1, 0, 3}, {1, 1, 1}, {1, 0, 3}, {2, 0, 2}, {2, 2, 3}, {3, 2, 3}}, 0.6558007729973042, 0.370765376916161, 0.8529002966356548, 0.05947346513961005, 0.5577279493397087, 0.9838074527812479, 0.5567568555585147, 0.295366207122625, 0.06071048168178976}, {-0.940257901337949, -1.7718107193847275, 0.12133828586931716, -0.748831997944578, -0.8051898640232127, 0.17545534063667764, -1.1683303497670532, -3.6703319448003042, -5.505661141263274, -1.017317163651109, -5.242442062468605, -9.09010941963297, -2.7312650371787908, -1.1929635163490304, -4.29616178873925, -4.504773228531546, -1.9685380554340846, -3.0955055516642673, -4.284005937996329, -3.2424680417075136, -4.9819317070485365, -0.9716193265855626, -2.201036023881267, -13.337337210518028}},{{{0.7368087400176295, 0.17082944105400538, 0.9943404059344649, 0.14751793766610805, 0.6112267209252764, 0.869987426825537, 0.07591179840661373, 0.7147756222049515, 0.8897534760061164, 0.044706770606639586, 0.9486243079778685, 0.21192174230005065, 0.9824199475028458, 0.40541049131389684, 0.1290851552841576, 0.5561209693027465, 0.6116545705866848, 0.5525101946782421, 0.06961169014454754, 0.9983930199630378, 0.6278471178054368, 0.9957533391197274, 0.7742454830219225, 0.9376825382812479}, {0.8910383777878073, 0.824923898065722, 0.7799050770874576, 0.7901646006151399, 0.27981165686253096, 0.9549364712401851}, {0.7039932786808438, 0.07538897841018838, 0.3900581808564145}, {0.9102297006335455, 0.7553689707029754, 0.8634672361101378, 0.40763823335356875, 0.5048192093196486, 0.6262838154188177, 0.3073462668073913, 0.7959836627668839, 0.9523090146414065, 0.5566721252742702, 0.3089532468443536, 0.16813654496144717, 0.9565556755216792, 0.7824266422523477, 0.3712707085631057, 0.2770981671736399, 0.13163177745595714, 0.0025215651648901275, 0.5811061079479658, 0.9972865103111089, 0.1766953062157721, 0.2985282864840463, 0.5057171295377774, 0.6072283294546944, 0.2664656055822266, 0.5431593157810709, 0.6422498934276396, 0.19959009610112569, 0.761646396262578, 0.9168755003622532}, {0.3349036266202483, 0.40360643333424173, 0.8093373816211714, 0.36020337508798295, 0.025950379775894705, 0.23546988837279453, 0.8527817060994923, 0.5777767328356352, 0.654679671212789, 0.9583717211991547, 0.7211499286435352, 0.5752551676707451, 0.0735735632648233, 0.9610852108880458, 0.5444546224277631, 0.27672688118669886, 0.567856433727046, 0.35385688143335137, 0.2779890168455365, 0.733567565405628, 0.9256065402994063, 0.15426678533222568, 0.5163426205829585, 0.8166920650433748, 0.590702913679158, 0.750660351997984, 0.707005238961787, 0.45648868995539177, 0.5647525339032633, 0.5151904636251894}, {0.8542235328622947, 0.8787119571197566, 0.9100728626904743, 0.5568187424260347, 0.13307360421875955, 0.3034567894490114, 0.8364992994256509, 0.595733531537989, 0.5886189817909965, 0.026729908262312578, 0.268642865698605, 0.24187665010463763, 0.31062996494545997, 0.2931623428566847, 0.3430363253991987}, {0.08760986477241196, 0.7942873443625015, 0.4764702778133099, 0.7523334117200408, 0.33694951277442803}, {{2, 1, 3}, {1, 1, 3}, {2, 0, 0}, {3, 0, 3}, {1, 1, 2}, {2, 2, 2}, {0, 1, 4}, {2, 2, 3}}, 0.08728210540071443, 0.019981587857918152, 0.18758087781677746, 0.8217590491492386, 0.23305857253841972, 0.14126963073816162, 0.27750801512630324, 0.26494030672320384, 0.09998496831966017}, {20.32265639390891, 84.18971011514006, -29.979277913983566, 83.90109968743289, -44.497836871417384, 9.742136461522522, 105.58449565806184, 12.349745681110965, -16.272134750953967, 97.63482747738789, -89.68228655135475, 96.54808353970206, -19.733888593576506, 51.50588232468168, 81.25663295645913, 29.301788931943104, -49.36499158892836, 47.03075258799754, 106.05365786505284, -28.493196492957857, 15.124710110894757, -27.71816387860136, -68.13428650465025, -1.5729984489983317}},{{{0.8378128412891502, 0.4410087157006523, 0.6692067751852149, 0.5113659865286637, 0.8110829330268376, 0.17236585000204732, 0.4273301250805772, 0.20073602158320375, 0.5179205901701529, 0.8293295246028486, 0.33972026030816527, 0.40644867722070227, 0.04145031235684301, 0.07699611288280786, 0.002770747533737264, 0.31916657181998787, 0.021468724498924854, 0.8894152350660304, 0.18101169838449868, 0.08610799928156815, 0.8801990937607632, 0.6119072199397272, 0.9160713916612948, 0.986123030961908}, {0.04238625247161304, 0.17089850423907485, 0.24686461647607996, 0.47475704443324424, 0.23130331944477542, 0.9985326542370275}, {0.8195344913955027, 0.2740210228500405, 0.7133827292746224}, {0.16920312963417894, 0.47981423108733745, 0.8675723456293382, 0.6719324169177795, 0.09220701675137108, 0.47704348355360016, 0.5484057738093504, 0.6504636924188546, 0.20279178168534068, 0.2960317851691015, 0.4622977745277822, 0.7702645986580914, 0.5908845617456135, 0.3799603935078067, 0.47617474356587425, 0.7278783461864783, 0.41998605750653867, 0.13309577703172673, 0.0014176991326299798, 0.4965750267417029, 0.42145340326951114, 0.31356128563622404, 0.7273966762825895, 0.7831922974670804, 0.25225027363533215, 0.8337470545488865, 0.8598243306532513, 0.11125988054930097, 0.1600432568839611, 0.3567035709952864}, {0.3114185568439009, 0.46079618813044637, 0.9572514751986204, 0.0606717858261849, 0.8491207823161188, 0.690531589472355, 0.36636691345300687, 0.6807113923183782, 0.3729460387502445, 0.9626532432858766, 0.9463808559464683, 0.5476156152866515, 0.3715283396176145, 0.4660782165441738, 0.5249274526769571, 0.23405432965042747, 0.644131663335025, 0.6828859190770934, 0.2726771790416249, 0.4003072751015409, 0.7843073326817738, 0.5716260385277924, 0.11263392215766384, 0.04360370410625449, 0.4728887758378728, 0.110829850397346, 0.15538244695904344, 0.9829319182800695, 0.623767993521754, 0.420298260924991}, {0.7890155335060366, 0.30222052596169136, 0.2508219547715096, 0.4576450176391143, 0.8426346775595683, 0.7546049106750399, 0.8792936151538951, 0.9915668010949406, 0.3177072248826112, 0.5205505810246124, 0.23516195181887006, 0.30868088201784716, 0.04503004584098631, 0.12024330592307153, 0.45085461913709635}, {0.7370548434900548, 0.9323961236833225, 0.07663960181681703, 0.9779658432992235, 0.6262249930927088}, {{2, 0, 3}, {2, 2, 0}, {0, 0, 3}, {2, 1, 3}, {0, 1, 0}, {0, 2, 3}, {0, 2, 2}, {1, 2, 4}}, 0.777013676724279, 0.09370768353674745, 0.35419784977746943, 0.2059267321677178, 0.9879981432182425, 0.791487157575056, 0.10337589500595981, 0.7482817145286035, 0.14536346565867417}, {-4.198600960395707, -4.665087959192179, -8.268836315746501, -2.961224841763216, -4.3475308540447966, -3.000342907453823, -1.4308081008598763, -0.8154715935197993, -1.109577377802608, -1.087639915075651, -0.5866042941256255, 0.4132065642007262, -0.040030510366694, -1.6017808118990438, -2.247984965898554, -1.1475661218945064, 0.07080843365622772, -6.919343966046391, -0.22960776687391854, 0.1404396995331682, -1.0490006083149828, -0.22716339198164798, -1.1341902984329928, 0.020554284091112908}},{{{0.036882246900016194, 0.22408227985206472, 0.756714913433663, 0.8276562407760629, 0.5163316658754038, 0.9889203280331946, 0.4480340314158159, 0.7826261949350766, 0.39608835995233227, 0.5380657088960983, 0.7109791879257611, 0.8502300712517541, 0.3194487581355152, 0.5600998655968749, 0.08475419483305227, 0.07321639452747508, 0.22574107459876777, 0.2059020158194054, 0.8788274626653345, 0.08521825130923259, 0.4342539170237117, 0.10252612081344559, 0.13054574813673095, 0.9398547856505585}, {0.3973716701236955, 0.8784438409613808, 0.37383083470306794, 0.11219854487449549, 0.8810400042482918, 0.8895235129281862}, {0.925796803287252, 0.32957234993941886, 0.4849516442959595}, {0.35145780403208793, 0.214817615361491, 0.47934227868766477, 0.16550288616044426, 0.7913579384352131, 0.1300634205284387, 0.40612588416018963, 0.9397618115616765, 0.5854559226158077, 0.25123595786310426, 0.3209076328509571, 0.5055078945379647, 0.48292980180236217, 0.1206902097263733, 0.38105284720039867, 0.10813622441426929, 0.6044859608409813, 0.7468593750233053, 0.2688543023259032, 0.22709622016597755, 0.7149624479127951, 0.8210625717360533, 0.9392819523864843, 0.7421445758700181, 0.36350464388070713, 0.6062449563745623, 0.45993967369881955, 0.5766416897095739, 0.572146705445494, 0.47618153584612366}, {0.053813789538629885, 0.6368798781478974, 0.9866907828296863, 0.2249455779830194, 0.7329061566876728, 0.13137198360993257, 0.5037609810273241, 0.1042553682566461, 0.35185330948727417, 0.023235759195663303, 0.8992750201863429, 0.3573959932333407, 0.08299900716137101, 0.7961395390296857, 0.1843125722735478, 0.5363334214972874, 0.14371705477488672, 0.05399496315966765, 0.8208079283928407, 0.930088465122725, 0.6837773810760672, 0.4773532734500938, 0.2486612229473467, 0.45390692927660137, 0.6299635915374373, 0.8404733953021964, 0.2619704401176604, 0.22896135129358197, 0.8970574348497645, 0.7091014116922638}, {0.7582094590903363, 0.12470598303693586, 0.5452041253624903, 0.6858656524966006, 0.8589344389039935, 0.7673099898035951, 0.4622051182011193, 0.8897261134669148, 0.6746218666304457, 0.23097656830630778, 0.3184880634262326, 0.8357311503072472, 0.853813938237605, 0.3008881031835828, 0.6347106823501654}, {0.35837787685715333, 0.6051527152902583, 0.8469811739069814, 0.004747090812728075, 0.5179044815549569}, {{0, 2, 3}, {0, 0, 3}, {0, 0, 2}, {1, 0, 1}, {3, 1, 0}, {3, 0, 4}, {1, 1, 3}, {0, 1, 3}}, 0.34318227517259786, 0.6180198226133994, 0.10768965596296358, 0.808803069862693, 0.5849728160822616, 0.4933138395764636, 0.5624855306004732, 0.12293741736609251, 0.7260383771782681}, {-0.5432265874328386, 2.8487422730668, -12.74400679890702, -16.509618952529152, -4.785258211327897, -19.244433387562168, -3.8683408038367455, -3.7293575629141698, -2.9703981961133703, -6.189201325586205, -5.066734006372011, -5.509264113371479, 0.6616283829033941, 2.703004406396548, 2.454501444189928, 0.3309908840967101, 5.564034443516316, 5.804516136300962, -6.673334679659579, 6.483035670485515, -2.456210919771986, -2.7533011688675275, 1.7546913990336126, -9.128277294738421}},{{{0.7260038497728684, 0.10028041239935395, 0.23321130389917769, 0.05141651054782252, 0.4950272814665606, 0.7817923489731213, 0.39748015359193056, 0.19760257231021758, 0.19413917828297786, 0.147081666622956, 0.03910227673477719, 0.5924498570199593, 0.3471580043759965, 0.1423345758102279, 0.5211977951798202, 0.2492675818473615, 0.729138181762597, 0.03464491984726433, 0.7123947253171272, 0.6642947657650999, 0.2358243421861335, 0.4721593892467911, 0.5894573079510347, 0.9382563885868318}, {0.5098204924132651, 0.3718789768474371, 0.356246004051857, 0.8868398780390093, 0.014793210946704475, 0.5900866278743158}, {0.9587658504599265, 0.6892373057287917, 0.8206540326637266}, {0.44300496125135974, 0.9196635737251493, 0.09678744870883235, 0.4734960282877302, 0.30067038544113184, 0.398465778545329, 0.8475198668614708, 0.7443578465251331, 0.26602546559386747, 0.6860710532282018, 0.1832251010963709, 0.5085335043389997, 0.7938660763470764, 0.09661374527716707, 0.24496871250953914, 0.9987130119257346, 0.4219870994996393, 0.74036774122531, 0.35812883447052984, 0.9839198009790301, 0.8319004716253235, 0.7816018907653836, 0.6688915287417382, 0.16326576831530348, 0.3888955103739638, 0.8619383170402343, 0.5721040800329058, 0.6897697400275733, 0.088225124932832, 0.4634725384949053}, {0.724584213171435, 0.9454118935024401, 0.8221996593389644, 0.7774014852667035, 0.541359112075064, 0.4368783891634405, 0.028333582991888064, 0.6807877399895365, 0.2963903995655249, 0.43816537723770593, 0.6063464834922487, 0.9404199987642263, 0.938261565094995, 0.4542455762586758, 0.7744460118669252, 0.1588181079988428, 0.2693700363532569, 0.2909798079433723, 0.3855505014929614, 0.2968797909586085, 0.697265956320351, 0.601210067915799, 0.29732537656012936, 0.8334072524637032, 0.9726817431489161, 0.6557981744133589, 0.47512571722116487, 0.056005767196999706, 0.43132263107385205, 0.21891978524991837}, {0.4467921342292768, 0.3752180272074633, 0.13493223150832717, 0.7807544080122124, 0.840445650737028, 0.4347980284432369, 0.1966706664133321, 0.3265088317535366, 0.06599963887010289, 0.2759799204443941, 0.9273006300600752, 0.03552902381016432, 0.6804491373771415, 0.9791001294857856, 0.23003467373972417}, {0.4343189558943653, 0.38312376081701216, 0.14569287702208242, 0.25735293059080805, 0.7785207814810065}, {{0, 0, 4}, {2, 0, 3}, {3, 2, 3}, {1, 0, 4}, {0, 1, 4}, {0, 2, 2}, {3, 0, 1}, {3, 1, 4}}, 0.9079980435958472, 0.0896871098250827, 0.826030299516956, 0.559600996231088, 0.4612059093665704, 0.7144690826176194, 0.6910980680086288, 0.7788465882188756, 0.6207602586295423}, {-7.135661212465537, -2.536130975549933, -2.677675482697439, -1.2209747791736694, -7.584129214674509, -2.048583997039465, -1.5378264258978462, -0.8210760391863859, -0.8530385346546498, 0.09425734044245221, -2.2780727506527687, -0.7318501196639369, -1.9222538895827945, -0.7066260748031359, -1.302510422870073, -1.1411697413166333, -5.63433865344752, -0.5642891956720208, -7.099746094011126, -2.7933346028564148, -3.143207644425952, -4.35139844764125, -10.347761135764888, -7.61944068510082}},{{{0.27967105417438254, 0.4944274015952967, 0.45233775646533897, 0.5547606197594395, 0.0036911337299884188, 0.5671267715352215, 0.41680873265517465, 0.8743114823822979, 0.024591004244202807, 0.33709209779549726, 0.9824897767608094, 0.4911877215652858, 0.8788981272221204, 0.07973916720468921, 0.20396899527980292, 0.5831896779694385, 0.7892110173970377, 0.2537088676877332, 0.6443679990487149, 0.12198376860286814, 0.07474193477941828, 0.5626107996791044, 0.8655214108298392, 0.5012235099733258}, {0.7950708806050357, 0.06818339808380769, 0.41318365436450033, 0.9464628902138863, 0.7913797468750473, 0.5010566265485862}, {0.9963749217093257, 0.07215140783158841, 0.7667887426308445}, {0.16396452875308895, 0.013885144948516337, 0.5809636862663026, 0.8878906154087242, 0.08422536154839975, 0.8099161496687134, 0.997774008296864, 0.09867959801168642, 0.8305164938606665, 0.16554815061999853, 0.8757902396939959, 0.023937663232268147, 0.2679056941815622, 0.30002673979015926, 0.3745667297206701, 0.2288667826272324, 0.19972229609775446, 0.8868430854256589, 0.42810383950678377, 0.43748703575218506, 0.6986656695491682, 0.8904681637163333, 0.35595243167519536, 0.6706982931213405, 0.5347011407960793, 0.876583018767817, 0.7749887454088927, 0.7828076777126165, 0.4504757792476795, 0.06666686909910352}, {0.7772147371120287, 0.68412807970093, 0.619959285387013, 0.901118718479105, 0.9014244974180328, 0.6601904164686618, 0.3520535912054508, 0.6010919786889457, 0.5268577676973627, 0.43132363384142947, 0.15233129510769636, 0.7142488932632868, 0.09875392819057892, 0.9938365980892444, 0.45366562555852813, 0.8237807295469535, 0.7428014965153835, 0.3231383049679038, 0.9189644847624489, 0.9471977107791366, 0.9678127511064908, 0.5403306272552874, 0.4684887055147693, 0.880530841680033, 0.19059801399446216, 0.8562025475543573, 0.8485294201277563, 0.9794121232009281, 0.28917351657642937, 0.19601213108569548}, {0.49647582892230546, 0.37832014451198237, 0.7623157488790667, 0.764688497244266, 0.34414453381460913, 0.6640712512486956, 0.6635618206884878, 0.7708518991550216, 0.890478908256081, 0.8402905217017421, 0.9207603241731043, 0.4477135941871178, 0.9715144234936322, 0.8930928109226055, 0.9529475730666134}, {0.9073829669318304, 0.5030257179788629, 0.0125619692425725, 0.7623495590721512, 0.05118041937747306}, {{1, 0, 2}, {0, 0, 3}, {2, 1, 0}, {3, 2, 3}, {0, 0, 3}, {2, 0, 0}, {0, 0, 4}, {3, 0, 0}}, 0.6544962978511066, 0.03314984604164442, 0.47317604249572187, 0.8551682882917776, 0.15802046892880112, 0.654829701529662, 0.7108602936166551, 0.09047979104751157, 0.813875935114192}, {-6.271556923731938, -8.016223989509385, -8.31434307798861, -13.08469391834489, -4.271030752101922, -5.380105057944531, -1.1358099086787432, -7.611288640898747, 0.691593400915755, 0.6179305009684442, -5.097602710125084, -4.721508967979393, -8.45357400936522, -3.267160083840477, 0.17353915784244434, -6.180341698850528, -11.374456186353358, -4.83293488543183, -7.2012043355343796, -4.2236290745067935, -2.732149596745323, -9.277818337542532, -16.644394968616368, -6.789692305428876}}};
  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float dloga[6 * 4];
      float dgamma[6];
      float dlogbeta[3];
      float dc[6 * 5];
      float dd[6 * 5];

      ParameterizedNormalDistribution prior_loga = 
        parameterized_normal_distribution (data[i].inputs.logastddev);
      NormalDistribution prior_gamma = 
        normal_distribution (data[i].inputs.gammamean,
                             data[i].inputs.gammastddev);
      NormalDistribution prior_logbeta = 
        normal_distribution (data[i].inputs.logbetamean, 
                             data[i].inputs.logbetastddev);
      NormalDistribution prior_c = 
        normal_distribution (data[i].inputs.cmean, 
                             data[i].inputs.cstddev);
      NormalDistribution prior_d = 
        normal_distribution (data[i].inputs.dmean, 
                             data[i].inputs.dstddev);

      dqfunc (dloga,
              dgamma,
              dlogbeta,
              dc,
              dd,
              data[i].inputs.loga,
              4,
              6,
              data[i].inputs.gamma,
              data[i].inputs.logbeta,
              3,
              data[i].inputs.c,
              5,
              data[i].inputs.d,
              data[i].inputs.pz,
//              data[i].inputs.priorz,
              data[i].inputs.ratings,
              8,
              &prior_loga.base,
              &prior_gamma.base,
              &prior_logbeta.base,
              &prior_c.base,
              &prior_d.base);

      for (unsigned int j = 0;
           j < sizeof (dloga) / sizeof (dloga[0]);
           ++j)
        {
          assert (fabs (dloga[j] - data[i].desired_output[j]) <=
                  2e-3 * (1 + fabs (dloga[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", dloga[j], data[i].desired_output[j]),
                   0));
        }
    }
}

typedef struct _DQFuncDLogBetaTestDatum DQFuncDLogBetaTestDatum;
struct _DQFuncDLogBetaTestDatum 
{
  struct
    {
      float    loga[6 * 4];
      float    gamma[6];
      float    logbeta[3];
      float    c[6 * 5];
      float    d[6 * 5];
      float    pz[3 * 5];
      float    priorz[5];
      Rating    ratings[8];
      float    logastddev;
      float    gammamean;
      float    gammastddev;
      float    logbetamean;
      float    logbetastddev;
      float    cmean;
      float    cstddev;
      float    dmean;
      float    dstddev;
    }                   inputs;
  float                desired_output[3];
};

static void
test_dqfuncdlogbeta (void)
{
  DQFuncDLogBetaTestDatum data[] = 

    {{{{0.13282017647014113, 0.5360946498204818, 0.6732007839668493, 0.7827562739934975, 0.9853801386029039, 0.4075616143602421, 0.8435577809182462, 0.7537214149150812, 0.12296654105713913, 0.5888030861886042, 0.09392546452328059, 0.24042463837638728, 0.029415374907986656, 0.7391621493125664, 0.6899430244035307, 0.6775984398968529, 0.1320262107138701, 0.9323078864818206, 0.5093637968672008, 0.19061747675789692, 0.7155284211886545, 0.8711834634914472, 0.5051192510588116, 0.04149408776455715}, {0.5827082447185133, 0.3350888136709653, 0.8319184670919623, 0.25873781377105975, 0.5973281061156095, 0.9275271993107232}, {0.9883606861737161, 0.5050163988559786, 0.4743615650584704}, {0.3387241131221191, 0.8944352216504355, 0.2645917604795913, 0.44494619015048376, 0.5995619638095526, 0.20449219724690482, 0.5869933205827385, 0.31291997943661365, 0.6672540773277321, 0.695128400379704, 0.3963758438248415, 0.5973915582479592, 0.796070613836285, 0.1900091493208924, 0.3548817560602843, 0.014683313529445786, 0.46098180016531964, 0.35809068222893015, 0.0961439422892246, 0.41735520741383625, 0.5334546008545964, 0.369729996055214, 0.591127543433246, 0.9429936423553659, 0.1947304877324773, 0.47529477440477846, 0.3265357829536547, 0.4980474522048821, 0.5951685239229246, 0.27080257715787365}, {0.7395424623709163, 0.18512747276826846, 0.9279144465951925, 0.5756741767781697, 0.3431666185460748, 0.5877359145203093, 0.13184383275890754, 0.3856650274572772, 0.9882848624857904, 0.5730526009908635, 0.6708620325935879, 0.027574345228347102, 0.8921409201965658, 0.15569739357702725, 0.1374074317389915, 0.6578443491731331, 0.3010133767633198, 0.2127037512216614, 0.9426769440065143, 0.18254957476835462, 0.9744775938096651, 0.7146562990167793, 0.34750842008358956, 0.911746997610481, 0.23493513143874886, 0.5295288262485108, 0.41959397348839705, 0.3360728208323113, 0.8917685128926741, 0.9417929117282016}, {0.2877501407294895, 0.9504077933750341, 0.9034836504068836, 0.36874031073733804, 0.6168881081359017, 0.922833448146687, 0.011342730210317849, 0.21304291716031076, 0.47948067639691017, 0.26498909897355394, 0.710329353446998, 0.0003391659386493646, 0.5368037323903959, 0.08243952420519929, 0.735851759637333}, {0.28568286692187006, 0.18929531230680638, 0.1706925265947183, 0.5009166281985841, 0.7561540406733592}, {{1, 0, 0}, {1, 0, 4}, {0, 1, 4}, {2, 2, 3}, {2, 2, 0}, {1, 1, 1}, {2, 1, 0}, {1, 2, 0}}, 0.7697013388184093, 0.834619705762407, 0.60914811530591, 0.8143611289451577, 0.4819511980889198, 0.8842119123873728, 0.7056644648990263, 0.4456208182078196, 0.8650630899530182}, {-37.500446626833124, -9.663894383416368, -19.01799738516764}},{{{0.9613784642406858, 0.6943217346887085, 0.23257790104750883, 0.38558241355610795, 0.6963893652671319, 0.9839923812417104, 0.23223873510885945, 0.848778681165712, 0.6139498410619326, 0.24814062160437753, 0.9465558681869894, 0.6594833688589056, 0.44325731446721434, 0.7472239934057935, 0.19040182751363022, 0.8897820300404963, 0.6086376087048073, 0.13807587809988345, 0.37604069856847255, 0.40783083195157654, 0.7244256963174345, 0.43241141320085713, 0.9304198803606529, 0.5427677419985584}, {0.7630472320767486, 0.7380896785121487, 0.6978419793131442, 0.15718532844245042, 0.06665786680961674, 0.7540972972704382}, {0.46560324420428467, 0.30840664727673844, 0.4527080257476841}, {0.5059566756660607, 0.5190473760172952, 0.6489232784178328, 0.0094507112804698, 0.7587326822602672, 0.32864554850366506, 0.7591412483773365, 0.40081310257566244, 0.6206568041603838, 0.9526048499351925, 0.35131041642575994, 0.676387406258228, 0.18824539095952667, 0.022184969574539512, 0.8085426744272015, 0.9133401741814793, 0.450155712447378, 0.32434299026139535, 0.6513573459847511, 0.8466823073718626, 0.6960584151769398, 0.8587397460571107, 0.3429506987080127, 0.39397428162417847, 0.19010173951087914, 0.3396923700398154, 0.6940274202901799, 0.38452357034370865, 0.43136905725061186, 0.011046821536150359}, {0.9348861719128434, 0.9837104677680462, 0.8107122530902281, 0.058441971600957876, 0.5835757554870834, 0.30732306150981825, 0.6224668621307015, 0.036257002026418364, 0.7750330810598819, 0.3939828873283389, 0.17231114968332342, 0.711914011765023, 0.12367573507513077, 0.5473005799564764, 0.4762527345063836, 0.8531742657079123, 0.7807250363671181, 0.1533262983322979, 0.2861509949955045, 0.5134818956680969, 0.08669761607693817, 0.7688027279885893, 0.8547819377448926, 0.5024350741319465, 0.15181144416409476, 0.785092260220543, 0.044069684654664494, 0.44399310253098867, 0.5682356886770114, 0.4777691987107248}, {0.42160282252396303, 0.4077361005045703, 0.7932026076171295, 0.08378631138238592, 0.24929167284063963, 0.6958220887395473, 0.6695268725419987, 0.5364857314259096, 0.7730389383342561, 0.842647823031635, 0.8888018361748806, 0.38315943309361167, 0.48688794333875157, 0.3291659273635381, 0.8021042200979425}, {0.6143567051050224, 0.632106005593859, 0.8267308532315916, 0.6502927759338476, 0.8292644448844794}, {{1, 2, 0}, {2, 2, 0}, {0, 0, 0}, {2, 2, 0}, {0, 1, 0}, {2, 0, 3}, {2, 0, 3}, {0, 0, 4}}, 0.5880363209391944, 0.3827377507006029, 0.08205708725683633, 0.3514952461737545, 0.1664334984152314, 0.9750016501960326, 0.2888544796397069, 0.2677089347913686, 0.9171418255745918}, {-31.249781329539378, -9.871219721546645, -28.01045222347597}},{{{0.2791795614564853, 0.6193276070977082, 0.7312232033654591, 0.14410288724033574, 0.4365317384248503, 0.7305257709228277, 0.3480637702718474, 0.6572149439015842, 0.10736581106131224, 0.9284215508248852, 0.7337070651668249, 0.025108938307725242, 0.2806349578297207, 0.27812877489103754, 0.9044426202823457, 0.43707261736853076, 0.8978972071291178, 0.1960716876342012, 0.5529473741085911, 0.2706391189532994, 0.9228955569330851, 0.9072172079944943, 0.2852384393172225, 0.3534972933787076}, {0.6437159954765999, 0.2878896008967861, 0.5540152359517635, 0.20939440613837187, 0.20718425705174953, 0.5573638299739585}, {0.20595146567991607, 0.5521794622367877, 0.09981844599043731}, {0.6289422791490733, 0.4722444005130911, 0.5270705239290624, 0.8191834881607166, 0.3508135042580357, 0.5678017802307455, 0.08999790656053165, 0.9212862810315988, 0.1547418166238345, 0.014854406122154344, 0.8193587876072322, 0.9983907240985137, 0.24752460862934017, 0.7296159668049319, 0.46586149422852463, 0.35467472862191385, 0.9596350077325541, 0.1756007308531684, 0.2564670880901528, 0.1474904715701643, 0.4022711777585956, 0.9696492651732523, 0.7042876258533651, 0.04767202557972698, 0.7733288986095224, 0.49740486466016126, 0.17721710192430268, 0.22848853741901035, 0.4225153943514866, 0.9296030844294159}, {0.08721919536377101, 0.3072022563874115, 0.26777357772765215, 0.9147486783072615, 0.26786040775653874, 0.30881153228889785, 0.02024896909831196, 0.18513271150232963, 0.8019989135280141, 0.9541368036669841, 0.06061396136575788, 0.009531980649161222, 0.5455318254378613, 0.8066463320968197, 0.6583427836071623, 0.03988271547590888, 0.8412441995844961, 0.7589743065170927, 0.8850138849976399, 0.5424778508157476, 0.6640270976601935, 0.5304857690980824, 0.46249849064615334, 0.6128747663863318, 0.5768079022964225, 0.22328351271067087, 0.1947249129185012, 0.6981260880790703, 0.30894749453988374, 0.914471980421773}, {0.17447594382018922, 0.5129933765767407, 0.5069485810118697, 0.9603351767547891, 0.11386198245443134, 0.5034613959275794, 0.9614167555740084, 0.15368884465796934, 0.45551919884726905, 0.4635786804516706, 0.12017255598951217, 0.3947145381408766, 0.5705053138496291, 0.921100829635923, 0.45614545832931863}, {0.8642287690427942, 0.1080068232034758, 0.3082260632495912, 0.8793375560328961, 0.6409452563321233}, {{3, 2, 3}, {0, 1, 2}, {0, 0, 2}, {1, 2, 3}, {0, 0, 3}, {3, 2, 0}, {1, 0, 2}, {2, 0, 2}}, 0.9132819102849746, 0.6100999751705208, 0.5703900614930124, 0.7264732759103503, 0.7388059664647854, 0.09710659859378018, 0.0634414804811427, 0.7661380991555612, 0.624943984010354}, {-17.05710810196838, -10.122934704105472, -10.421679446270268}},{{{0.5936452026662007, 0.10202472490713434, 0.6124492544975919, 0.16942478516308498, 0.1300665222145301, 0.9818521689176222, 0.21773471635671532, 0.5989194713134559, 0.20896569257860714, 0.5257067105883035, 0.3535059473139211, 0.4909126481099801, 0.900739629329016, 0.6463691545554073, 0.7125606909817978, 0.5776307378250055, 0.2906396541584951, 0.075979093062395, 0.9860874150714475, 0.83882477136022, 0.1935330555647149, 0.012537612581252302, 0.2199493159158862, 0.21388078734986601}, {0.5998878528985142, 0.910512887674118, 0.6075000614182943, 0.04445600218678102, 0.4698213306839841, 0.9286607187564958}, {0.389765345061579, 0.4455365308733251, 0.26085563810537693}, {0.4029540081681923, 0.03625939774765791, 0.9546238827633451, 0.360116008776361, 0.7565848536127849, 0.32369870676586016, 0.3769931449383396, 0.06947635461786593, 0.6806057605503899, 0.3376112916944127, 0.5381683735781195, 0.875943299053151, 0.6680681479691376, 0.11766197577852648, 0.3242875862282535, 0.2760554461546369, 0.7575552602950196, 0.5101619143602322, 0.27983158404147246, 0.8062341154706528, 0.8288945415385238, 0.12039656929865317, 0.8342950531681473, 0.5453784773652759, 0.42594053337033155, 0.08413717155099526, 0.8796711704048022, 0.18526246858891487, 0.6693556797575466, 0.7604384647851351}, {0.5026780254664627, 0.11578611397104895, 0.9887499192071567, 0.42282717309072243, 0.9645096518883431, 0.23984281491789788, 0.3206817712380191, 0.30516519731219593, 0.6402220656600897, 0.963787368763261, 0.5631265109429995, 0.7950032829519638, 0.3603904816186172, 0.15755325329260822, 0.7342319694044757, 0.6746067136533106, 0.5260954284504699, 0.6121747759273324, 0.30829143603414405, 0.5904695421023154, 0.6464242580456676, 0.42691230733841745, 0.6389357562765975, 0.8300310773171803, 0.14374623257920494, 0.3111261933673685, 0.6501858370694408, 0.40720390422645786, 0.17923658069086176, 0.07128337844947064}, {0.32950406583142167, 0.10203870691426191, 0.5390145150307721, 0.1074960096862096, 0.7663775548884222, 0.30703542396229816, 0.1786240334121549, 0.9499427563936014, 0.03214558548394663, 0.6324287103089875, 0.6525286049616851, 0.33776798046626905, 0.7238541494498025, 0.041959168206672205, 0.0061043469160174625}, {0.9108556731278515, 0.0849183931732051, 0.21192809088949197, 0.8623581143368125, 0.5997294797604831}, {{0, 0, 0}, {3, 0, 3}, {1, 0, 1}, {2, 0, 0}, {3, 1, 1}, {0, 2, 4}, {3, 2, 2}, {3, 0, 4}}, 0.4347325561037643, 0.8047241866630341, 0.6831215336459507, 0.5284461013110124, 0.10522849027234267, 0.7026854797487723, 0.14410701861517866, 0.4209500916248028, 0.3388509353839204}, {-12.82186351468638, 2.577260009696655, 17.12172450303601}},{{{0.39565005578647405, 0.9654829852030238, 0.4710073352312014, 0.3067053498999738, 0.7632213454774865, 0.3129543802413387, 0.13323935476493237, 0.5828512004501712, 0.7212621772708143, 0.30685003332532124, 0.2223836816370808, 0.49793280727696615, 0.5093340863813224, 0.4444919189885087, 0.6226542018765978, 0.0632002511732018, 0.7046098997182882, 0.7613703853425579, 0.09420810056558536, 0.9579717609008591, 0.0019244199695160134, 0.6172633667273792, 0.6732580089407826, 0.6191208255169387}, {0.6062743641830419, 0.6517803815243555, 0.20225067370958114, 0.3124154756169649, 0.8430530187055554, 0.3388260012830168}, {0.06901131894464875, 0.7295642751667937, 0.12179084143474109}, {0.03197596795769561, 0.846627637307568, 0.23163146788982752, 0.6124567550534187, 0.5874840489691869, 0.22397343543097015, 0.16843121671662573, 0.9078468553351305, 0.8261136636266291, 0.1297653348653848, 0.21045945581576658, 0.9059224353656145, 0.20885029689924978, 0.45650732592460225, 0.5913386302988279, 0.29964807118257253, 0.5570699153748943, 0.25425665221502114, 0.278923154681863, 0.45659505247701715, 0.21824391409187743, 0.18524533327037238, 0.5493588795150693, 0.33480421104227603, 0.18626794613418182, 0.33861769596280444, 0.3177274116252418, 0.7223474559888573, 0.5987838971649949, 0.11464426053183428}, {0.1492961949086161, 0.8145006006537269, 0.7726702335383658, 0.9848789256664495, 0.9388367390928495, 0.9085781652881123, 0.5638199366391161, 0.5283715997418472, 0.3474981087940216, 0.6089300941055398, 0.006750021264221809, 0.27411494752682614, 0.06857495411215861, 0.15233504162852268, 0.7885061071723444, 0.08886961425645377, 0.5192160745970893, 0.8175308305862466, 0.6022381610381625, 0.7502519182936493, 0.20148866297184745, 0.09518337459738932, 0.0034542638731676605, 0.635607657761815, 0.052192468063231336, 0.2806827739436625, 0.2307840303348018, 0.6507287320953655, 0.11335572897038182, 0.3721046086555501}, {0.6669640936956858, 0.12235713235351829, 0.7658576201763602, 0.7631745145500103, 0.6602140724314639, 0.8482421848266921, 0.6972826660642016, 0.6108394729214877, 0.8717079652591195, 0.7593725705702383, 0.17806659146711235, 0.793308642335241, 0.269469804220957, 0.009120652276589047, 0.9765779284952649}, {0.6981252677378517, 0.26601554034778935, 0.373512994514774, 0.9243854604320335, 0.4174424937941892}, {{3, 2, 2}, {2, 0, 2}, {1, 0, 0}, {3, 0, 2}, {3, 2, 2}, {3, 1, 4}, {3, 1, 3}, {0, 0, 2}}, 0.035231510012987535, 0.7227842624194084, 0.8110297314616517, 0.04533788513863903, 0.3682674163173018, 0.6004271300658901, 0.04517211128529152, 0.2821633705886287, 0.7080533438858378}, {-9.832395897498301, -27.896996256116545, -5.885655946450254}},{{{0.752184945239198, 0.34788944522108994, 0.6713238976671411, 0.8363453786267183, 0.9928123746689597, 0.16982285375397757, 0.8780152553319001, 0.5668755744057613, 0.9836917223923706, 0.19324492525871267, 0.17988998759404845, 0.300860034057972, 0.6101787278775965, 0.2688594648266791, 0.7624474937998593, 0.2656285240449845, 0.8873944654581881, 0.45782973336502736, 0.7171096086612202, 0.8973611077276826, 0.28696733539229796, 0.41265762207973583, 0.43494623807259153, 0.18930776384184478}, {0.5347823901530999, 0.06476817685864593, 0.7636223404054504, 0.3529623852151264, 0.5419700154841404, 0.8949453231046683}, {0.8856070850735503, 0.786086810809365, 0.5582782930917698}, {0.7017003978459557, 0.7057170974795018, 0.4852267767513931, 0.9480995652141732, 0.43284093301927656, 0.9432696036796426, 0.2195982527064086, 0.060705099755985086, 0.9750111996542492, 0.22615999501842238, 0.3222371449787259, 0.7737377643636871, 0.5623535775745133, 0.7912137569458308, 0.13292938113688113, 0.23895537421058713, 0.4975854007158674, 0.027591416540380418, 0.7799669959217547, 0.6969853587264467, 0.6026400776111991, 0.1419843314668301, 0.9938801851123896, 0.138707065634677, 0.9009396797652434, 0.4362672339873282, 0.5086534083609966, 0.1906075004205038, 0.4680987467459668, 0.49299763030768556}, {0.289055155654588, 0.12990240066451872, 0.49308754709171765, 0.2668376352892632, 0.966818010675862, 0.3561646363008316, 0.9307339695172043, 0.47562387834343234, 0.8338886295389809, 0.11720926209024446, 0.4331485688013369, 0.4480324618030519, 0.053921633617226246, 0.42022390336379767, 0.8305084911901378, 0.30604813033622186, 0.06004144850483663, 0.2815168377291207, 0.9295688114248944, 0.8697808963488937, 0.55138804014384, 0.09090933730861687, 0.46147006467892765, 0.3767832660412081, 0.26233288448925207, 0.9610069366440982, 0.9683825175872101, 0.10994563075194488, 0.29551487381339003, 0.6048423003432666}, {0.03764854807000573, 0.6343217524085125, 0.46162624427440907, 0.48763303825302207, 0.6044999792686688, 0.18628929060546062, 0.40770461065718283, 0.06740913488922441, 0.773991488078531, 0.8802411602692388, 0.3476631621523462, 0.7858922971601038, 0.8444226766536366, 0.010460263920345133, 0.7962751220085061}, {0.6949829598514868, 0.38295261197470887, 0.6336769978791371, 0.5339422375192541, 0.7339760232073888}, {{3, 2, 2}, {0, 2, 4}, {1, 2, 3}, {1, 0, 4}, {1, 0, 4}, {3, 1, 4}, {1, 0, 2}, {0, 0, 4}}, 0.41457009438749887, 0.5237313671271921, 0.23842736370586404, 0.12913372286412217, 0.37692154631749314, 0.8894096147186796, 0.7768011194314549, 0.6415006846111001, 0.7724215670488243}, {-61.27090705861537, -16.362738168153744, -28.378277408965182}},{{{0.703120324113219, 0.36909650877427214, 0.5740915497218757, 0.9984300789702932, 0.8228791638439803, 0.02143334662192591, 0.7881992525617719, 0.15400740231665674, 0.8124188999236351, 0.22515822461341978, 0.09321629271028507, 0.7710547903419479, 0.17874190204449805, 0.6912159870941658, 0.3592402695028964, 0.356484695954449, 0.6550105349173059, 0.4527886233883017, 0.2301065466387742, 0.9795631496369559, 0.7656009201986262, 0.6759875039568467, 0.5886058620276742, 0.2071415825881316}, {0.062480596085407195, 0.3068909951825746, 0.014514312305798452, 0.2087115036178383, 0.23960143224142694, 0.2854576485606487}, {0.22631505974402652, 0.054704101301181536, 0.42718253231779185}, {0.06029942394722895, 0.13309876703374143, 0.2836493109592337, 0.24844063027329377, 0.3690834368530632, 0.7738584975308451, 0.9271646150047846, 0.5934300953559879, 0.9162948134647615, 0.5437519508920708, 0.9476014653678289, 0.8278291751573617, 0.24030730950791476, 0.9551460888643968, 0.7404598827796972, 0.7653485790719545, 0.9334163143253401, 0.9406317765585983, 0.5317483791618589, 0.5257471468305275, 0.6479586657646914, 0.7143167168145718, 0.4770442778606774, 0.0985646145127357, 0.5876592418174624, 0.5812179497808303, 0.19339496690144373, 0.8501239842394419, 0.21857580496439924, 0.8073594522499853}, {0.26623035189665906, 0.256693888883454, 0.3022809914996377, 0.2636075013579144, 0.31862888652883026, 0.42886471372609236, 0.061973681991722936, 0.30846141249351766, 0.578169003749133, 0.6635161346541378, 0.1285573676663828, 0.36782963593491935, 0.04642062458727409, 0.13776898782361036, 0.4805987019016914, 0.6535129191203476, 0.5693763467265966, 0.03920437331087466, 0.892939460084229, 0.07229496933951723, 0.375981379825153, 0.18908038907143274, 0.6743636551198297, 0.26493551708953195, 0.10975102792849394, 0.9323865001879788, 0.372082663620192, 0.001328015731617578, 0.7911221413996636, 0.5035217864618864}, {0.31010898162846906, 0.6928666032380999, 0.21295313765053067, 0.8400056518077484, 0.18155161396208627, 0.32503696730318055, 0.1665325130632566, 0.7022366639841381, 0.7009529120603949, 0.671524048182833, 0.5971561663366599, 0.6630322906732634, 0.8080134519761659, 0.5992290788433158, 0.2211747865115069}, {0.4739519016018307, 0.13364979685633624, 0.3342935617537838, 0.11142375858301296, 0.541565401413852}, {{3, 2, 0}, {1, 2, 4}, {2, 1, 1}, {3, 0, 3}, {3, 2, 2}, {2, 0, 2}, {2, 0, 0}, {0, 1, 3}}, 0.7615671332361442, 0.3329655460221662, 0.32030161718334926, 0.03804361495196565, 0.45145815160767516, 0.6400989427840663, 0.1073484795328186, 0.19803796314421718, 0.2699065376455889}, {-12.891509179410232, -8.136671098728065, -22.921272000776362}},{{{0.3150619754808857, 0.940815966469562, 0.4958012991600791, 0.568953625585194, 0.6435379272980527, 0.34365980013290215, 0.8327690084868157, 0.7609401736090281, 0.04430884845473696, 0.12248501362139526, 0.3588171068849849, 0.6272903767526918, 0.7100152867009532, 0.0110612550383823, 0.8172517054711329, 0.8657232435165476, 0.377049740678787, 0.690759637855033, 0.7792080905191673, 0.41426509190887245, 0.7369507978947207, 0.5834111583222145, 0.5811701273749501, 0.14435855426328353}, {0.421888822413835, 0.6425951918526523, 0.08536882821487102, 0.5754049286780895, 0.7783508951157823, 0.29893539171975025}, {0.2525998197280554, 0.8144647550690614, 0.7340420466610453}, {0.17645037809835498, 0.8937827128430704, 0.1871743783163695, 0.024026759960092153, 0.1653891230599727, 0.07653100737193752, 0.32145113479982185, 0.6469770192813051, 0.47462948520493964, 0.29732291685277024, 0.9071860428909494, 0.9100262213865845, 0.8912183268827252, 0.7161527894778201, 0.7628274886276659, 0.48813739897274944, 0.24862313503007283, 0.6307839612629491, 0.1874225599495764, 0.7097865038569672, 0.9496877433103226, 0.37818414153489377, 0.37295780488051505, 0.9757444571959218, 0.7732373652119676, 0.4844014286918233, 0.18578342656414554, 0.9517176972358297, 0.607848242151995, 0.40787042131988577}, {0.8643322917643237, 0.3047406779545245, 0.1332187569470553, 0.11054750446711553, 0.9571462488733743, 0.39471445656794, 0.24200043006433006, 0.3943947149892954, 0.19431876024570835, 0.9065770575951906, 0.9933772950342572, 0.7636107537263462, 0.0068962002961319435, 0.1967905537382234, 0.04368955172393464, 0.3854266121914525, 0.6339383954156169, 0.2210460965423016, 0.270452186511967, 0.9010251834996292, 0.4481549688514714, 0.2693283993064719, 0.662603944359972, 0.4931547621797434, 0.5838226770871477, 0.9645877213519474, 0.5293851874129168, 0.3826072577126279, 0.6266764282137735, 0.5698732647840073}, {0.28738475734858676, 0.9882125427233325, 0.4323576679680651, 0.6632962071888168, 0.29400746231432956, 0.22460178899698627, 0.42546146767193316, 0.4665056534505934, 0.2503179105903949, 0.8391751768055338, 0.7915230722563162, 0.2454595569082918, 0.9798657240784279, 0.9381499933059045, 0.34336810340484486}, {0.9761311576018199, 0.31726177971845576, 0.44499523112616113, 0.7595454263176972, 0.011543436249872478}, {{2, 1, 3}, {2, 2, 1}, {1, 0, 1}, {2, 0, 2}, {3, 0, 3}, {0, 0, 0}, {2, 2, 0}, {0, 1, 1}}, 0.787876592305539, 0.06238797341353323, 0.13286899810392375, 0.44167017146586507, 0.5004918349569522, 0.0741754306902007, 0.7005113301358586, 0.7783739642770483, 0.20648437264262265}, {-18.343993083155876, -20.593193341856043, -44.70389297512324}},{{{0.8495736416932145, 0.2750498624639255, 0.3118683108264549, 0.9561664620522278, 0.010398464887680661, 0.48352679020760925, 0.06640875391816307, 0.9763007379737999, 0.0722484715817761, 0.1401586868027644, 0.09027759631634318, 0.6590389582553441, 0.6272532404556149, 0.3806132604850672, 0.0787341600664707, 0.8711623659498051, 0.5648652670420817, 0.24774426238114347, 0.6370639886006056, 0.37067053099285296, 0.490689836351881, 0.5472329322452848, 0.8586900243235573, 0.16418615835023032}, {0.6411161946586666, 0.2721830697813593, 0.5468217134971024, 0.20801969629800257, 0.630717729770986, 0.7886562795737501}, {0.48041295957893937, 0.2317189583242027, 0.5584692581892099}, {0.6484975927709856, 0.3901353632625962, 0.5726800000688586, 0.9312160177335949, 0.26788433228591846, 0.31140120319612546, 0.7015176341190534, 0.3663507506915131, 0.020140069904775, 0.6743372145955199, 0.33084710312620047, 0.8756609143396321, 0.4729071376594902, 0.8156471902719625, 0.16666094477597013, 0.2345447196809655, 0.20072406787813088, 0.26882547677486013, 0.9586412484779675, 0.6038269899099795, 0.41206778830438084, 0.7884125171959208, 0.7269222901537649, 0.0453577317207697, 0.7635701955333952, 0.3982771539333245, 0.15424229008490625, 0.11414171398717482, 0.4956858632474767, 0.08687595073719906}, {0.4527246559658528, 0.7477909632956616, 0.4755457933427017, 0.4125387361416792, 0.12187755283965236, 0.8721300489560295, 0.0026386556832115166, 0.5968915458697166, 0.9552166080636822, 0.6375853292750641, 0.8019145878050806, 0.3280660690948565, 0.9965753595857146, 0.03375833936508452, 0.3898467995006998, 0.5396535518989358, 0.26965306943194983, 0.9884006076443148, 0.6262766039673047, 0.14137639796561124, 0.11541077934704358, 0.87425889365714, 0.1305907407198279, 0.05450044722841218, 0.6626861233811907, 0.12646793036147833, 0.6550449473771262, 0.641961711086733, 0.5408085705415384, 0.2543378814054488}, {0.6524062916939147, 0.04507016521701635, 0.5855919624778562, 0.6167525521303847, 0.850491703888834, 0.7170040961221599, 0.5890166028921414, 0.5829942127653002, 0.46064490438813427, 0.17735054422322402, 0.31936353346019164, 0.5945936051209854, 0.8343683004208297, 0.0359741462576128, 0.20395275411314806}, {0.7203347114638453, 0.7037775597010018, 0.9814736990292006, 0.5412666307319574, 0.593866781102367}, {{3, 0, 2}, {3, 2, 2}, {2, 1, 0}, {3, 0, 3}, {0, 1, 1}, {1, 0, 3}, {3, 2, 0}, {0, 1, 0}}, 0.04873261232387553, 0.3395119879424676, 0.0004580601904189206, 0.33952889969691824, 0.39632632062996087, 0.2944418227254513, 0.4148660977125628, 0.7227763475665335, 0.5458346167411268}, {-19.884882786661894, -12.10412146700413, -12.404208366128927}},{{{0.5774377266032914, 0.8258494948204214, 0.13978213480123336, 0.08518971235299255, 0.4000871823800674, 0.5064859613602297, 0.545188529680248, 0.2508214119321629, 0.3641130361224546, 0.30253320724708166, 0.8248538182164027, 0.5470438522311611, 0.382639337093254, 0.7612665765151243, 0.23098703711403568, 0.49831123990728565, 0.04312734915078638, 0.7608085163247055, 0.8914581374171174, 0.1019849192773248, 0.7486855264253351, 0.34594241861214264, 0.16868178985058394, 0.556150302536198}, {0.17124779982204363, 0.5200929237917213, 0.028899655049350575, 0.47096059018320546, 0.7711606174419763, 0.013606962431491633}, {0.48371112536910255, 0.2201391782510425, 0.4070475813195216}, {0.71107375518441, 0.6588573071526999, 0.6730953260198813, 0.024408244226267597, 0.9498071786692857, 0.4278702700386642, 0.1747840861125957, 0.9812808950754812, 0.18899866234458024, 0.5364121326215467, 0.07279916683527088, 0.23259536865014613, 0.8430562437324376, 0.36773034277096284, 0.5166488642990729, 0.061347568828102474, 0.32296331994071625, 0.33883068772161223, 0.045688274115867455, 0.29018695138612627, 0.30935635750922463, 0.8551195623525096, 0.8255490958648249, 0.8831393700666046, 0.5982826023248147, 0.19626225519980978, 0.1524537698449436, 0.8587311258403371, 0.648475423655529, 0.7683919851611456}, {0.977669683732348, 0.8774502307648558, 0.4594767613109488, 0.23197985253959882, 0.904870516897077, 0.6448548621147097, 0.6164205175785111, 0.864249509768636, 0.3882216525980041, 0.5835072932866072, 0.29345719763779493, 0.5254188220470238, 0.34253337848213666, 0.29332034190048095, 0.9841008401285704, 0.6702992596945141, 0.5169842826173118, 0.4101809718338763, 0.3858182378037557, 0.4740370044947043, 0.36453051277236814, 0.5514498459935393, 0.7373428141482267, 0.7056450193335587, 0.3868608290400202, 0.6739996152286835, 0.27786605283727794, 0.4736651667939599, 0.4819903121429432, 0.02914475311397376}, {0.6614455352587667, 0.6094156570253239, 0.09376865954493906, 0.4456374598273665, 0.36798833762097183, 0.0839968349783001, 0.7512352810628024, 0.15231711792688554, 0.38388749749240153, 0.413697575283786, 0.2342509984454906, 0.7421361460930093, 0.9980692596886459, 0.9396605707890816, 0.8697204856731224}, {0.19068630009946994, 0.2607264455404192, 0.23401555145552289, 0.4828596566331022, 0.5166866848707865}, {{1, 0, 1}, {2, 2, 3}, {1, 1, 0}, {3, 2, 2}, {0, 1, 2}, {0, 0, 3}, {1, 1, 2}, {0, 2, 0}}, 0.9828603927031413, 0.760350384661563, 0.0008693444901590234, 0.4875419317568127, 0.3214148574443745, 0.15093472763623908, 0.90710068494522, 0.04190447192944618, 0.9534265198234027}, {-9.415120998841303, -11.549389503856395, -31.909788550211427}}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float dloga[6 * 4];
      float dgamma[6];
      float dlogbeta[3];
      float dc[6 * 5];
      float dd[6 * 5];

      ParameterizedNormalDistribution prior_loga = 
        parameterized_normal_distribution (data[i].inputs.logastddev);
      NormalDistribution prior_gamma = 
        normal_distribution (data[i].inputs.gammamean,
                             data[i].inputs.gammastddev);
      NormalDistribution prior_logbeta = 
        normal_distribution (data[i].inputs.logbetamean, 
                             data[i].inputs.logbetastddev);
      NormalDistribution prior_c = 
        normal_distribution (data[i].inputs.cmean, 
                             data[i].inputs.cstddev);
      NormalDistribution prior_d = 
        normal_distribution (data[i].inputs.dmean, 
                             data[i].inputs.dstddev);

      dqfunc (dloga,
              dgamma,
              dlogbeta,
              dc,
              dd,
              data[i].inputs.loga,
              4,
              6,
              data[i].inputs.gamma,
              data[i].inputs.logbeta,
              3,
              data[i].inputs.c,
              5,
              data[i].inputs.d,
              data[i].inputs.pz,
//              data[i].inputs.priorz,
              data[i].inputs.ratings,
              8,
              &prior_loga.base,
              &prior_gamma.base,
              &prior_logbeta.base,
              &prior_c.base,
              &prior_d.base);

      for (unsigned int j = 0;
           j < sizeof (dlogbeta) / sizeof (dlogbeta[0]);
           ++j)
        {
          assert (fabs (dlogbeta[j] - data[i].desired_output[j]) <=
                  1e-3 * (1 + fabs (dlogbeta[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", dlogbeta[j], data[i].desired_output[j]),
                   0));
        }
    }
}

typedef struct _DQFuncDGammaTestDatum DQFuncDGammaTestDatum;
struct _DQFuncDGammaTestDatum 
{
  struct
    {
      float    loga[6 * 4];
      float    gamma[6];
      float    logbeta[3];
      float    c[6 * 5];
      float    d[6 * 5];
      float    pz[3 * 5];
      float    priorz[5];
      Rating    ratings[8];
      float    logastddev;
      float    gammamean;
      float    gammastddev;
      float    logbetamean;
      float    logbetastddev;
      float    cmean;
      float    cstddev;
      float    dmean;
      float    dstddev;
    }                   inputs;
  float                desired_output[6];
};

static void
test_dqfuncdgamma (void)
{
  DQFuncDGammaTestDatum data[] = 

    {{{{0.05143229330150596, 0.20294598382395065, 0.21382994955475015, 0.2046515461791441, 0.6208986832570362, 0.13743864331901315, 0.4880744771141468, 0.8848437530162767, 0.9151319944827694, 0.7719631514215117, 0.15759705204317934, 0.7240372019212858, 0.2111416188119216, 0.4210963076423014, 0.5581296610440518, 0.09595158359563268, 0.13660884028397385, 0.374208768054181, 0.2765244492689462, 0.5851529358287019, 0.751465138323542, 0.028371033327778645, 0.8377085626359131, 0.6815727703669701}, {0.700032845022036, 0.825425049503828, 0.623878613081163, 0.4769212241878259, 0.07913416176499978, 0.6879864061848149}, {0.13580413596701618, 0.5920774711715492, 0.16400216728223035}, {0.9160232547633032, 0.9782070839238368, 0.8680402692502635, 0.9528605484703088, 0.4949269471210017, 0.420077422879785, 0.7720886856546307, 0.8162517081863349, 0.1207181790668207, 0.14355297361083882, 0.18693574982592884, 0.06478656986279292, 0.09234714573904206, 0.3058444109749257, 0.5053629794589588, 0.3647537248407569, 0.26692209623521407, 0.6819657978937628, 0.028441755271132914, 0.28561956307575714, 0.5789356900503992, 0.5461616619267465, 0.43636428409958367, 0.12161739579352676, 0.6629124352870961, 0.5679545780029097, 0.5683240148493203, 0.168756847323218, 0.16798548816609438, 0.14787715512312471}, {0.7962353291946895, 0.3525051391368831, 0.04726730909927367, 0.004324181512285882, 0.6092995793687607, 0.2877185692740902, 0.9549201633602317, 0.6984797705373602, 0.10393659990980186, 0.9229648444333333, 0.6879980671250175, 0.016513972643597455, 0.07549484463866896, 0.6373452813575762, 0.1090623770746183, 0.4703523107168509, 0.6391305605390852, 0.5157278855640494, 0.4461499417875222, 0.9023977327139412, 0.07080654568976501, 0.34697103824083136, 0.27816445362142783, 0.7545205775908165, 0.2745712164950755, 0.9944658991039482, 0.23089714452215415, 0.7501963960785306, 0.6652716371263148, 0.7067473298298581}, {0.27597698116192254, 0.05171662554117041, 0.5613350372165129, 0.7837824853965248, 0.587978914036905, 0.035202652897572954, 0.48584019257784394, 0.1464372040389487, 0.4789165369622867, 0.564850342180722, 0.8467096320387587, 0.6307093184748993, 0.032766595174764504, 0.6624526094667809, 0.7759030863489936}, {0.28373828023406794, 0.7546021415533367, 0.9079320318759644, 0.5013318698539182, 0.28927238113011966}, {{1, 0, 1}, {2, 1, 2}, {1, 0, 2}, {3, 2, 2}, {3, 0, 3}, {1, 0, 2}, {1, 1, 1}, {0, 0, 1}}, 0.5237049970311826, 0.15773563579743383, 0.8360602327276034, 0.5825250513002616, 0.24772801586926, 0.10601901025626342, 0.27472519551109054, 0.7987425659037367, 0.659749101832355}, {-7.240178941900414, -5.358443473025339, -0.8745530854958494, -3.3980990369137967, 5.34923183856306, -3.8019245567639555}},{{{0.07081635735869046, 0.7888850029332466, 0.652305361864788, 0.1808325648700683, 0.5059660151779685, 0.9421753708944879, 0.021596043389888717, 0.14806596969530378, 0.8435134057111875, 0.16627228454549425, 0.7378577631558207, 0.3934638281419671, 0.9355813738352231, 0.664940414691576, 0.4485853820257011, 0.8697588311107846, 0.7778457380377893, 0.8288801819639726, 0.8660603307254395, 0.6220308152415246, 0.6718267277815259, 0.5541549864528821, 0.06731776482170276, 0.9622817134091696}, {0.6010103704228354, 0.7652699835196355, 0.4150124029569147, 0.7814491485391013, 0.09504435524486698, 0.8230946126251476}, {0.393416359567026, 0.6333831788437975, 0.25153094953367944}, {0.6568223280796534, 0.6555585964112053, 0.2399193507018304, 0.31594957569845633, 0.9918819133880773, 0.20697321438550417, 0.37016051959104584, 0.538103837660667, 0.16300173142410468, 0.34091288366006467, 0.7481297043495212, 0.8662771098791412, 0.6088467449712226, 0.2735951188383619, 0.7858479909403516, 0.2652667394563058, 0.843576761451587, 0.8585827158814472, 0.0043988424012503715, 0.17022238421143882, 0.02048214882643942, 0.4651663563144212, 0.37101566355745286, 0.9186914346777594, 0.36365982074678604, 0.809607759903216, 0.13109631285562245, 0.602741858979303, 0.37177790735870875, 0.6026345455177118}, {0.7609357932645766, 0.06463802131863595, 0.20877617593460404, 0.2617216618576471, 0.012806088915055384, 0.19836091143949477, 0.5999294309633815, 0.9881265430192853, 0.22695809797470373, 0.933094171983189, 0.7563526695117944, 0.12954382713783802, 0.22255925557345335, 0.7628717877717501, 0.735870520685355, 0.6643774708234168, 0.8515435920160005, 0.8441803530939908, 0.372210699938569, 0.8547697109202009, 0.720447279160378, 0.24143849411468776, 0.0004327925798602323, 0.2521351654024891, 0.9595114858958014, 0.1768004727960518, 0.7916566166452562, 0.990413503544842, 0.946705396980746, 0.9784395613565571}, {0.19172718568187475, 0.002286960525556773, 0.7197472990060423, 0.04534538937336808, 0.43537451617008033, 0.8727431333877187, 0.49718804343258893, 0.28247360160161794, 0.6995039954847253, 0.20836566256430192, 0.6456444514165884, 0.43829324850762713, 0.3272932955461564, 0.353595951644101, 0.9251971722562105}, {0.1968547543929394, 0.32686050296629615, 0.10146078624161191, 0.9656856863604091, 0.020054281596887574}, {{2, 1, 1}, {2, 2, 2}, {3, 1, 2}, {1, 0, 2}, {0, 0, 4}, {3, 2, 3}, {0, 2, 3}, {0, 2, 4}}, 0.53520388632104, 0.11104728269676992, 0.01898028937966305, 0.041614720240330534, 0.3434767006391652, 0.10876032217121315, 0.2992329903736208, 0.9962693308669625, 0.9081021844690849}, {-1361.838239711296, -1818.939812642009, -840.4191245986668, -1865.657177032197, 50.387047237124854, -1977.1081831200534}},{{{0.2360171887834944, 0.8020449469410318, 0.7137957292653445, 0.20859818898435953, 0.027651526219192497, 0.15640049552444338, 0.2755024807577174, 0.8813048934382032, 0.6740555745750915, 0.23120332326823295, 0.07864772636477799, 0.554444390471907, 0.5725947883334795, 0.26551763690782393, 0.05859344476789041, 0.019240504150867054, 0.46154750563670965, 0.24653734752816087, 0.01697872452755988, 0.6757638035117018, 0.3527871834654965, 0.9473043571545401, 0.020709393660597424, 0.767661619042617}, {0.11676999468200208, 0.14525941021350824, 0.3069136643952529, 0.5590634300582574, 0.08911846846280959, 0.9888589146890648}, {0.03141118363753554, 0.6777585366200543, 0.4150628938877181}, {0.7576555914208319, 0.9527634572727576, 0.12331414614814727, 0.8424681055542386, 0.492137954513008, 0.8941700125048672, 0.10407364199728021, 0.3809205999175289, 0.24560060698484715, 0.8771912879773073, 0.42830983848557835, 0.028133416452032413, 0.29829624983030706, 0.8564818943167098, 0.6606482194429614, 0.9113634217700304, 0.15303683961679881, 0.5495682299214569, 0.10158478938470396, 0.8222449533072207, 0.16417792492773395, 0.5181570462839213, 0.4238262527646497, 0.40718205941950264, 0.40652233350690203, 0.5653935890111639, 0.3005121066165024, 0.564713953865264, 0.914384378993894, 0.6712235765062967}, {0.1964384646192222, 0.18379335394773516, 0.6687837720090469, 0.7940322885289894, 0.7681286261336439, 0.15565993749570275, 0.37048752217873987, 0.9375503942122796, 0.10748040669068243, 0.24429651572567243, 0.21745068256194103, 0.38798216429082266, 0.005895617305978467, 0.4220515624184517, 0.05327275763420709, 0.8698251180069012, 0.5820693645413287, 0.014869502998949069, 0.646750424127305, 0.3044315289957374, 0.2815572579248264, 0.450155549133685, 0.732366045133411, 0.6332079524894407, 0.08511879330560417, 0.26636219518594983, 0.0635822731243641, 0.8391756639604513, 0.3169901671719603, 0.11070225769024708}, {0.6930947509456242, 0.9016252697481717, 0.20950976048127792, 0.8664057419645746, 0.4756440683836832, 0.513643105457349, 0.20361414317529944, 0.444354179546123, 0.42237131074947615, 0.6438179874504478, 0.6215447786339706, 0.4294846765471739, 0.7756208866221711, 0.3393864584547104, 0.3399875207091443}, {0.9793291274134889, 0.04325484148876008, 0.7061785059652697, 0.2548687274035401, 0.712966932227539}, {{1, 2, 1}, {3, 0, 1}, {2, 0, 2}, {3, 0, 2}, {0, 2, 3}, {1, 1, 0}, {2, 2, 3}, {3, 1, 2}}, 0.979672568364396, 0.8670028420048184, 0.9378785602315798, 0.602264674537292, 0.28657781741877175, 0.9653775722566467, 0.7283687997503019, 0.7358589325727173, 0.8109337490350885}, {1.5135060002508782, 2.949802405488154, 1.2322838145188624, -0.5146183717110215, 1.1261582935838141, -2.462443473841292}},{{{0.45173446679929763, 0.5247546565750024, 0.29150475302659434, 0.38856243828561243, 0.8079164793488498, 0.9032098779410318, 0.8620200764794205, 0.6129415516634413, 0.4685300208941395, 0.5632223572318875, 0.8826909490659316, 0.5696867101746812, 0.7623515149288698, 0.30835362982834735, 0.16972401683839247, 0.5900141418102852, 0.8953486729240514, 0.37047506959676757, 0.5674593423011005, 0.3034363243915135, 0.9299711006674047, 0.6421062698464657, 0.8316004097283831, 0.492502575356425}, {0.47823663386810716, 0.11735161327146326, 0.5400956567017888, 0.10394013707081257, 0.6703201545192573, 0.2141417353304315}, {0.6780755802223684, 0.49099858540737124, 0.20179013362511786}, {0.650919378098544, 0.7953846311564368, 0.92131187523269, 0.43943861869624806, 0.3425657482701967, 0.6256606143180443, 0.3312977334224047, 0.5440899457721966, 0.9720906786734291, 0.05820127201694384, 0.027861409030891196, 0.6141188451047919, 0.32998440882696345, 0.2266008622885607, 0.5353588336744662, 0.13588221123668473, 0.21263279555550021, 0.6865052055867719, 0.4314186966036537, 0.4655620567174274, 0.9984910602250687, 0.008429625364403552, 0.9404201111962824, 0.26377192309230957, 0.3475716821265247, 0.21304499420796677, 0.019108235963592467, 0.8243333043960616, 0.005005933856327964, 0.5873843798899224}, {0.6878105025411878, 0.2802433586238649, 0.03291525518289881, 0.5291831078729786, 0.6599490935102965, 0.6661245135190731, 0.7029308463559354, 0.30258224558441793, 0.12459025983583034, 0.5302423022823883, 0.49029805080043515, 0.6160770399976461, 0.6931715632321767, 0.06468024556496091, 0.4918069905753664, 0.6076474146332425, 0.7527514520358942, 0.8009083224726513, 0.14423530844884175, 0.3946024204252757, 0.7336432160723018, 0.9765750180765899, 0.13922937459251378, 0.8072180405353533, 0.045832713531114025, 0.6963316594527249, 0.10631411940961498, 0.27803493266237467, 0.38588362002081744, 0.030207145933651865}, {0.40338327305367966, 0.9754526870779567, 0.2612933601849871, 0.49996484365126354, 0.9130852222532445, 0.3593756470803107, 0.5681217969528104, 0.4352845980863026, 0.4212782316778781, 0.7517282324470683, 0.8153703449169162, 0.6343762756136513, 0.27704292322903634, 0.35712581202179255, 0.08172712884461439}, {0.6578012575370614, 0.13781354863652254, 0.5499077714864393, 0.03589441531350037, 0.9614695980843365}, {{0, 0, 1}, {1, 1, 1}, {1, 0, 2}, {0, 1, 1}, {1, 0, 1}, {2, 2, 3}, {2, 2, 2}, {2, 2, 1}}, 0.031499429226907565, 0.27187283882406466, 0.6500107952926829, 0.9312624521506847, 0.6281161561732279, 0.29642015174610786, 0.3887174351076958, 0.43129760849942117, 0.7150309339199834}, {735.8621759375812, 1290.4887241388358, -303.64818459889506, 1782.41740123218, 741.111074630543, 1491.0510672736636}},{{{0.9370445046657971, 0.8205956381548853, 0.9960130104131185, 0.29375270224210537, 0.18531627221872884, 0.005225293237969192, 0.36163673479946723, 0.01670977901306902, 0.8281904601969363, 0.9234981643933547, 0.7038354772624058, 0.8788962303765465, 0.27828268871049694, 0.8876037490798544, 0.7423658791780692, 0.8473968011496389, 0.0064098498864323195, 0.23759295378717152, 0.8111034270273846, 0.21928064497641098, 0.7099896981403244, 0.8488755186794757, 0.3798058185279634, 0.5042497110564276}, {0.7729451934745273, 0.028279880524590347, 0.38379280811484484, 0.2104970088143222, 0.5876289212557985, 0.023054587286621155}, {0.02215607331537763, 0.19378722980125318, 0.7594384610588621}, {0.09955642289326636, 0.31832059605297186, 0.3148909994247067, 0.4811557723483652, 0.21195267381341193, 0.5759547168749026, 0.4674941982750678, 0.47474592246193287, 0.9743597200262404, 0.764851289847518, 0.24821355329865682, 0.7647562243216084, 0.12548420134676472, 0.3850454713195547, 0.7439638422422292, 0.9918110308470811, 0.09720432082217435, 0.0012526632047098276, 0.533466833427907, 0.4041821095912827, 0.0741497335355532, 0.9790965898893322, 0.33967960362665384, 0.6447436485324205, 0.9745933106422868, 0.6607759938363603, 0.02478860420194714, 0.16358787618405535, 0.762640636828875, 0.08482127696145772}, {0.5572944059268793, 0.6888419537221225, 0.7882809168026345, 0.31996998711393965, 0.30908085262822255, 0.924085729400514, 0.6627967154558698, 0.934924515794385, 0.5651170103859933, 0.9322746985534329, 0.5655923946336954, 0.9336718525896751, 0.031650176958086224, 0.5280925889621502, 0.4914426610981422, 0.9545752627003429, 0.6919705733314324, 0.8833489404297297, 0.5168493504558553, 0.29379926886398255, 0.6671819691294852, 0.7197610642456743, 0.7542087136269805, 0.20897799190252483, 0.10988756320260588, 0.030919110523551795, 0.965927796824346, 0.8890080047885852, 0.8008067105743834, 0.10683338112303775}, {0.3031310813684762, 0.9540834889942003, 0.2356897001883901, 0.17455868256960486, 0.7375386867347807, 0.020411636404525167, 0.2040395232303039, 0.6464660936074547, 0.24609602563663857, 0.06583637370418226, 0.5120689498988715, 0.763117153177725, 0.7292466751807831, 0.7720371048401997, 0.8448869807693863}, {0.043356088932050764, 0.9750379615538027, 0.5630591129376749, 0.7349994175667804, 0.012436978408498969}, {{3, 1, 1}, {1, 0, 1}, {2, 2, 2}, {2, 0, 4}, {1, 2, 2}, {0, 0, 4}, {0, 0, 0}, {1, 1, 0}}, 0.00911016472945671, 0.6740511081490896, 0.934192706992397, 0.9056035972854612, 0.7059790833609805, 0.7199676191548894, 0.6985030068040069, 0.7310449147158563, 0.9684403966261997}, {-8479.079340007976, 22063.128944765933, 20982.13776573831, 24960.259526986032, -12954.262905557083, 18480.701538406138}},{{{0.6995559827503642, 0.49446348357370307, 0.08457882110840167, 0.7223443709895612, 0.633719609046182, 0.9823945336748315, 0.32146166793067665, 0.9930976958087779, 0.8616825042059822, 0.13750755290544525, 0.27810557899862587, 0.018059734254975285, 0.2986233912683074, 0.40250813533866486, 0.2656686005901269, 0.008949569525518574, 0.6245722831192178, 0.4683154283462678, 0.3600650033046657, 0.3029704861645381, 0.9046046639643284, 0.7698124215422609, 0.6290200885888093, 0.33453008953833835}, {0.2050486812139642, 0.27534893796855786, 0.5444412674804077, 0.6121857185487772, 0.5713290721677823, 0.2929544042937263}, {0.222979599549731, 0.6190880227399992, 0.7096465679618}, {0.15544685138828107, 0.9448740205511051, 0.6010282884850239, 0.4110231766934926, 0.7529387160496163, 0.6792054199609783, 0.5920787189595054, 0.7864508935742749, 0.2846232877033484, 0.31914041665631254, 0.2891082327949673, 0.8818462296099464, 0.5148108661610874, 0.6901203280675032, 0.9545781432566289, 0.6767975483959823, 0.2394619281925296, 0.14567906058709554, 0.34239242470785175, 0.1054684762282, 0.9465075238988032, 0.9226994610373646, 0.7233044019678525, 0.3958219082664, 0.7910606725105221, 0.9778254404862594, 0.12227611348282862, 0.9847987315729074, 0.03812195646090596, 0.29862002052528114}, {0.5301973945233233, 0.19834783799863256, 0.7534986687575576, 0.9794796038689686, 0.241089161728356, 0.31650160838868613, 0.23868780259647013, 0.2893592758014654, 0.2865110184717271, 0.6397040599927039, 0.9992258744039405, 0.14368021521436988, 0.9441185937638753, 0.5342355837645039, 0.0527183505051373, 0.22098075417700536, 0.22081419179602282, 0.13841367549810382, 0.26165767799461515, 0.243155313690746, 0.0985380783131942, 0.15361494392519642, 0.22353572153370918, 0.9445352931654648, 0.5683406837898709, 0.9552671059265638, 0.4700370527761516, 0.9650556892964962, 0.3272515220615149, 0.6387654975378777}, {0.23134925017968144, 0.6756964134950308, 0.04074050358978782, 0.999061437545174, 0.2321233757757409, 0.5320161982806609, 0.09662190982591247, 0.4648258537806701, 0.1794050252706036, 0.3110354441036556, 0.8758077180298897, 0.32641217828256625, 0.9177473472759885, 0.06788013041290956, 0.7772696397166955}, {0.17279723435736982, 0.6942116257422793, 0.12334483724744473, 0.20892895592682456, 0.217530128430806}, {{0, 0, 2}, {2, 1, 2}, {0, 2, 4}, {0, 2, 4}, {0, 0, 2}, {1, 1, 3}, {1, 0, 3}, {0, 0, 1}}, 0.22417457296612772, 0.1582891479509485, 0.8816774338653096, 0.5787646308929282, 0.9928253227864463, 0.4825927344559177, 0.8409369302755219, 0.5797031933477543, 0.7607019470107054}, {17.043082163818454, 21.571834848036886, -1.7151438486044182, -16.704530766236207, -2.9171773321641505, 12.392546772993082}},{{{0.9505765361752567, 0.7443150204496094, 0.11487733956708425, 0.5812969217401017, 0.6395410920716013, 0.8685073024197197, 0.788465161284518, 0.6635495744641133, 0.5716609616586916, 0.09123766270302423, 0.6156679269271482, 0.969337948721834, 0.4483161244112469, 0.8823087067761997, 0.3981377984963422, 0.7451633757557062, 0.2900269764602984, 0.0006312729108900246, 0.8193731676034139, 0.75233805296926, 0.8074342420043807, 0.1596943426353682, 0.23966997425565964, 0.9916361059585547}, {0.856857705829124, 0.41537932218575885, 0.12479263468857538, 0.41033918421845283, 0.21731661375752276, 0.5468720197660392}, {0.3363274734040574, 0.7467896097543395, 0.6456556520988311}, {0.4556343570630149, 0.7206595464769092, 0.7774516610325055, 0.19733952768758417, 0.5733256502868153, 0.322521747980567, 0.03228828527679928, 0.9073125512272857, 0.5726943773759252, 0.503148580377153, 0.2799502323075393, 0.09987830922290503, 0.413000034740557, 0.26347860612149343, 0.2883141263489846, 0.24302060339378107, 0.9976207125547981, 0.13868597143291805, 0.8779749421305317, 0.02570398963625831, 0.45074869278875906, 0.8023584980288607, 0.13118533237619223, 0.3800483375374272, 0.9951143357257441, 0.08169895155195149, 0.35373367134368666, 0.18270880984984303, 0.42178868543892895, 0.7591772035713845}, {0.3214453860668874, 0.2753962586225573, 0.8490943080630038, 0.2560286231942314, 0.04149515375934812, 0.17551794939965223, 0.43609427332244677, 0.992550017072738, 0.7531810274103635, 0.9324973460058712, 0.4384735607676486, 0.85386404563982, 0.8752060852798317, 0.9067933563696129, 0.9877248679788896, 0.05150554761095927, 0.7440207529036394, 0.5267450188321856, 0.9926105322531453, 0.9698065960590078, 0.39028708155995284, 0.3440362089823426, 0.5708218468142164, 0.2106293924876233, 0.06884169549306543, 0.06863995035978537, 0.7217275387512126, 0.9546007692933919, 0.027346541733717308, 0.8931220009601332}, {0.28563326542876594, 0.9620507522206538, 0.27416551432335384, 0.960624654954262, 0.8471597046611173, 0.10818670658083389, 0.3989594290435221, 0.05383129858464911, 0.8594348366822279, 0.05668115896987462, 0.6549386761398827, 0.5270862797524635, 0.8668243044290824, 0.08687456291086684, 0.2646515945799298}, {0.1830500707701208, 0.29600245761486604, 0.8762451704232436, 0.1958098990868644, 0.11441012041033545}, {{1, 2, 2}, {0, 0, 1}, {2, 0, 1}, {3, 1, 2}, {2, 2, 4}, {0, 2, 3}, {3, 1, 0}, {3, 2, 1}}, 0.5742749188636533, 0.9216444011298517, 0.16846335735314708, 0.22128811945020233, 0.28864165343488735, 0.9595936489091978, 0.8942978430297932, 0.26066346449594036, 0.44148194877376995}, {1.007169922275583, 22.026347993547944, 32.301708853772816, 17.822508815872688, 27.594236076428203, 15.154133638042277}},{{{0.851406942328364, 0.49533841398627115, 0.20683216591129125, 0.5820471120915421, 0.7947257833584893, 0.8403997378463886, 0.6797458861588278, 0.7152228076624597, 0.7078512204476225, 0.5757481432664587, 0.496695815388707, 0.41922035004759367, 0.8316060500243789, 0.3799382441795943, 0.3822856949783715, 0.8449454311839404, 0.9099616488945272, 0.21147488682644727, 0.1609975755281692, 0.5563037777490529, 0.9503679999853294, 0.317177043796654, 0.9003341110322288, 0.114821828975283}, {0.09896105765696542, 0.8218386298103829, 0.6935019451209377, 0.5327747168837409, 0.3042352742984761, 0.9814388919639944}, {0.013756058962109803, 0.8175519092212812, 0.5963840538508536}, {0.4056907486975357, 0.5170602435734029, 0.39833155917368757, 0.7647780038264747, 0.02575250451794135, 0.1347745485950313, 0.5533861279897472, 0.8548163549319474, 0.8142776176914941, 0.9737769730668621, 0.9970823502406942, 0.904448354946618, 0.4971005738948401, 0.07344286203463322, 0.8822605212654112, 0.8054872972896526, 0.6752619440844572, 0.37994091691369564, 0.3494858043816704, 0.5012520229911765, 0.6938230521204628, 0.36618485795158584, 0.5319338951603891, 0.904867969140323, 0.2881323034229271, 0.849124614378183, 0.13360233598670163, 0.1400899653138483, 0.26237979890498575, 0.7143500657831517}, {0.5802162079969544, 0.28527361038190086, 0.44810218121349166, 0.7405730927162896, 0.5831338577562601, 0.3808252554352828, 0.9510016073186516, 0.6671302306816564, 0.7008733364908489, 0.5753379581456302, 0.27573966323419447, 0.2871893137679608, 0.35138753210917856, 0.07408593515445362, 0.5819166111137317, 0.921004455816375, 0.8194536369487894, 0.16921796601413064, 0.29378430769080455, 0.07187984143819198, 0.6858513009620878, 0.02912800070028235, 0.03140450878581881, 0.3575297756550403, 0.10563509296513336, 0.7438543903183815, 0.5833023275723271, 0.6169566829387506, 0.5225012352088733, 0.3630291348830987}, {0.6323007202536756, 0.9498264522570943, 0.8216278987180243, 0.7876911767374685, 0.35656105701948104, 0.6626371384891334, 0.4702403666088458, 0.7136052415830149, 0.7746444459057494, 0.7416326826727585, 0.6507867296600565, 0.5443872755688842, 0.48086013821494483, 0.6697528412345665, 0.9649354286979687}, {0.5152592748686019, 0.44945562942912604, 0.3122230655795262, 0.8593003357328353, 0.7714048845502204}, {{3, 2, 2}, {0, 2, 0}, {3, 2, 1}, {3, 0, 3}, {3, 1, 3}, {3, 1, 2}, {0, 0, 0}, {2, 1, 1}}, 0.8661533018567988, 0.6952663826407756, 0.33679910052396206, 0.4083757496671217, 0.23385258160312336, 0.7454399303836813, 0.5151712018059378, 0.6206845729296532, 0.8772915245836423}, {8.093243073167418, -2.636117626111023, -0.686466205451442, 1.6841623687698664, 5.9595204590382345, -5.641684107723311}},{{{0.08280279189454785, 0.044930835197092005, 0.9070793313466383, 0.1026470786778929, 0.34117010922178936, 0.3941441055370356, 0.3626920557777541, 0.621786940462948, 0.6714172679872229, 0.42920867683906694, 0.8474327809091522, 0.17233131103382204, 0.35919420240769667, 0.5699083411062317, 0.07602789635893181, 0.30617800917702315, 0.6639278197669211, 0.23310924058226956, 0.6676521466918101, 0.0723254275738998, 0.9184878893832398, 0.7179380387763318, 0.04696757376215688, 0.1950339029902575}, {0.8356850974886919, 0.6730072035792398, 0.13988824241551853, 0.09238682431236461, 0.49451498826690254, 0.27886309804220416}, {0.7771961866377645, 0.47059988384941653, 0.8230977202796796}, {0.8496544212031373, 0.9297634057286123, 0.2982685728155945, 0.463903517871983, 0.2797460800969056, 0.8537355093696805, 0.9920905636385713, 0.7999756981050619, 0.04663683951463604, 0.18608336267787032, 0.9197651360646715, 0.8814878087218221, 0.32869880073830426, 0.13911578891571344, 0.724731233074414, 0.04580271123313021, 0.6556915971590644, 0.9992275465001949, 0.6323444087620494, 0.5512877229662276, 0.3768284991168603, 0.22203135986243044, 0.16174452491263286, 0.728190002686548, 0.5271740779137231, 0.29226795413381823, 0.8634759520970384, 0.264286484814565, 0.24742799781681743, 0.43853244476413783}, {0.871385388458467, 0.4643107867095031, 0.20079115830218142, 0.2524490820862675, 0.9516202523937956, 0.582822977987681, 0.8720923575638772, 0.11333329317055404, 0.22688901931938152, 0.5370202667545507, 0.21640076040481268, 0.11410574667035914, 0.5945446105573321, 0.9857325437883231, 0.8395722612879524, 0.8920743868079287, 0.43280008564469924, 0.2575425411017751, 0.31239818337422937, 0.5998064326741105, 0.5693241335476609, 0.99325605628721, 0.06497018555741191, 0.16127398790997266, 0.6979387450891938, 0.5289452695777069, 0.8641790272552305, 0.9088249058237051, 0.7463184926953983, 0.946122291590026}, {0.9920866696913534, 0.7954916126531512, 0.5194294733760167, 0.4091020248354752, 0.7756859092865407, 0.6813858659827919, 0.9248848628186846, 0.4233694810471521, 0.9361136479985883, 0.7893114791748633, 0.4920847771739854, 0.16582693994537703, 0.6237154646243589, 0.18950504650075284, 0.9227606436263246}, {0.17257088365816697, 0.558745279066947, 0.028231058590780192, 0.22482189853713072, 0.64362561408046}, {{1, 2, 3}, {1, 0, 3}, {3, 1, 2}, {1, 2, 4}, {1, 0, 2}, {0, 1, 1}, {0, 0, 2}, {0, 2, 4}}, 0.6945662518117165, 0.11940615276707503, 0.4785034058417324, 0.697503322490434, 0.7024795821203632, 0.3239145401139239, 0.9590739324657156, 0.2884012976549588, 0.9267936728338225}, {-7.005425130358033, -5.284776620556718, 4.0841933349466615, 2.577313457694015, -1.801125089830544, -0.946895347391291}},{{{0.6425286741311319, 0.034189069647030945, 0.8650318166078067, 0.9906800248352342, 0.8532171949562686, 0.5421042924730455, 0.6992048766624297, 0.36696456021087526, 0.6637121484555157, 0.619343648846721, 0.5266339930042627, 0.8082192811439283, 0.6354810898647355, 0.39452175030959025, 0.8830083789238027, 0.11365302933221173, 0.5160749370976605, 0.9160183444678579, 0.18550505643336868, 0.41117344721184856, 0.19216039698373663, 0.9569444120021422, 0.8971037587784099, 0.48437977437802604}, {0.5496317228526048, 0.9227553423551113, 0.03207194217060315, 0.49369974954279183, 0.6964145278963362, 0.3806510498820658}, {0.33286706550817347, 0.12673518933191655, 0.03270237944082039}, {0.7613074010353448, 0.8062330725039107, 0.3185159081879883, 0.3972212895760848, 0.36678565072575453, 0.9232246935801081, 0.20486287885577656, 0.8811463524784243, 0.4507673062578967, 0.7377196371467395, 0.793689431643928, 0.6889859554946877, 0.49382289425575443, 0.8406158783683296, 0.3093096572659019, 0.13935423264208294, 0.5710675519006432, 0.8085439361977265, 0.8156099077231102, 0.4429397047457468, 0.1904165020185774, 0.47567687068955294, 0.6888747183911935, 0.4102373253049264, 0.4291091009832326, 0.6694437981856421, 0.37035881020320527, 0.013016035728841581, 0.06232345025747808, 0.7462191046055341}, {0.16549593134742868, 0.13186968325041729, 0.6115561439995814, 0.008499467458794617, 0.37180649970350066, 0.4428837277557296, 0.11773324974382697, 0.16788358909046502, 0.06249684243759873, 0.30352949511364663, 0.5466656978431839, 0.3593396528927386, 0.2468869347144886, 0.8605897903678998, 0.3562491958246064, 0.8836627822031856, 0.5580122163232951, 0.45035246506297344, 0.9271400948413738, 0.21421898401754347, 0.1876534061200898, 0.43733642933413186, 0.8648166445838957, 0.46799987941200943, 0.022157474772661112, 0.30546674608371455, 0.2532605005843143, 0.4595004119532148, 0.6503509750691604, 0.862583018327985}, {0.13552725084048733, 0.29161682286274976, 0.5878541326315617, 0.5590535232143383, 0.5888615529973036, 0.9322771699700112, 0.3409671979170731, 0.6984637328464385, 0.23261235717269713, 0.048614387766825556, 0.782954981593778, 0.24811126778346507, 0.3054722623313233, 0.8343954037492821, 0.5953015754736882}, {0.8107748384493332, 0.4406556177474276, 0.3663955243372726, 0.5731441007010271, 0.5053080923656187}, {{0, 2, 0}, {0, 2, 2}, {0, 0, 1}, {3, 1, 3}, {3, 0, 0}, {1, 0, 2}, {3, 2, 4}, {2, 1, 3}}, 0.1873951171631133, 0.9068951123840578, 0.9227931256318667, 0.6427250740376337, 0.051867866322625945, 0.615278289521308, 0.33493899300030494, 0.08367155082329536, 0.46300631332532244}, {-0.6001418445136295, -70.75861194539644, 71.5239616970279, 20.584397849000048, 0.45704073539233914, 35.59022560909601}}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float dloga[6 * 4];
      float dgamma[6];
      float dlogbeta[3];
      float dc[6 * 5];
      float dd[6 * 5];

      ParameterizedNormalDistribution prior_loga = 
        parameterized_normal_distribution (data[i].inputs.logastddev);
      NormalDistribution prior_gamma = 
        normal_distribution (data[i].inputs.gammamean,
                             data[i].inputs.gammastddev);
      NormalDistribution prior_logbeta = 
        normal_distribution (data[i].inputs.logbetamean, 
                             data[i].inputs.logbetastddev);
      NormalDistribution prior_c = 
        normal_distribution (data[i].inputs.cmean, 
                             data[i].inputs.cstddev);
      NormalDistribution prior_d = 
        normal_distribution (data[i].inputs.dmean, 
                             data[i].inputs.dstddev);

      dqfunc (dloga,
              dgamma,
              dlogbeta,
              dc,
              dd,
              data[i].inputs.loga,
              4,
              6,
              data[i].inputs.gamma,
              data[i].inputs.logbeta,
              3,
              data[i].inputs.c,
              5,
              data[i].inputs.d,
              data[i].inputs.pz,
//              data[i].inputs.priorz,
              data[i].inputs.ratings,
              8,
              &prior_loga.base,
              &prior_gamma.base,
              &prior_logbeta.base,
              &prior_c.base,
              &prior_d.base);

      for (unsigned int j = 0;
           j < sizeof (dgamma) / sizeof (dgamma[0]);
           ++j)
        {
          assert (fabs (dgamma[j] - data[i].desired_output[j]) <=
                  4e-3 * (1 + fabs (dgamma[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", dgamma[j], data[i].desired_output[j]),
                   0));
        }
    }
}

typedef struct _DQFuncDCTestDatum DQFuncDCTestDatum;
struct _DQFuncDCTestDatum 
{
  struct
    {
      float    loga[6 * 4];
      float    gamma[6];
      float    logbeta[3];
      float    c[6 * 5];
      float    d[6 * 5];
      float    pz[3 * 5];
      float    priorz[5];
      Rating    ratings[8];
      float    logastddev;
      float    gammamean;
      float    gammastddev;
      float    logbetamean;
      float    logbetastddev;
      float    cmean;
      float    cstddev;
      float    dmean;
      float    dstddev;
    }                   inputs;
  float                desired_output[6 * 5];
};

static void
test_dqfuncdc (void)
{
  DQFuncDCTestDatum data[] = 
    {{{{0.23130447700037843, 0.35556858170819566, 0.39790403640182737, 0.6929014641470504, 0.9093238863586633, 0.5538423797909636, 0.5755795697370468, 0.7095107750953753, 0.19387036910774377, 0.6969270847031243, 0.047404303807347815, 0.6218278883955651, 0.6933834315608749, 0.9628159531513955, 0.47663484104767195, 0.6114055026436868, 0.7940248344224972, 0.3909213966231836, 0.12624076823520874, 0.715977840996376, 0.6584321327445359, 0.8518836621895556, 0.3403728778120475, 0.6588552423077645}, {0.42712765574415745, 0.4963150804813599, 0.9424688414102201, 0.965953778160714, 0.5178037693854941, 0.9424727006903962}, {0.36688927167317326, 0.2564430030653388, 0.3239334002777503}, {0.24554561598727204, 0.3194849678658254, 0.6346151146697736, 0.6305499687168754, 0.2827296628358766, 0.8428501268181535, 0.023209612026086904, 0.8365251342943782, 0.8918082662126929, 0.7166093585829447, 0.30723177102971094, 0.17809300154984237, 0.0399246040231374, 0.3762364807708973, 0.6483765287219464, 0.7509653458056849, 0.5436095235417775, 0.43376763936067714, 0.6824227505612324, 0.2331615764201908, 0.6011368228513813, 0.06687836768750392, 0.4259797474958935, 0.9092281761424404, 0.3555912068641092, 0.7473933998216785, 0.7913646328261199, 0.2786782074255651, 0.07286154402823261, 0.904543273003525}, {0.768155020800033, 0.44215307313118685, 0.18105327781553965, 0.18793391442058027, 0.46092324977032206, 0.2640600715813445, 0.14112867379240224, 0.811697433649683, 0.8125467210483757, 0.5130947257756596, 0.5975191502506247, 0.37792979428900586, 0.13012397048714336, 0.27993314935546876, 0.9963823273992435, 0.3110514266015019, 0.7041442229912499, 0.37070497321302825, 0.6407911205351343, 0.5636580267798235, 0.91277959016513, 0.09202676578746315, 0.5679295765069017, 0.6591147537762984, 0.14462456936509696, 0.6498736926562763, 0.3868762986913621, 0.47118083935571814, 0.6837013195947749, 0.3858136210749318}, {0.24574762489895982, 0.6594834057060351, 0.8711545985463992, 0.8727188952992723, 0.6482284746483351, 0.2815536114170293, 0.7410306280592559, 0.5927857459438034, 0.6518461472490915, 0.9705021848155274, 0.03688640506800601, 0.22208077273077517, 0.011055026713957238, 0.40684415803570395, 0.12410681490287605}, {0.13005400694331204, 0.4431254502070555, 0.7477294042594056, 0.9794822455377791, 0.4801803142870357}, {{1, 1, 1}, {3, 0, 1}, {2, 2, 4}, {2, 1, 4}, {0, 2, 1}, {1, 2, 3}, {1, 0, 3}, {1, 1, 1}}, 0.05624915151569347, 0.2765485649036874, 0.29578092594300415, 0.09436669321210393, 0.8105015266167337, 0.6170651591976523, 0.42462632739660494, 0.2216477979128317, 0.16227305196839859}, {0.863142466615157, 1.0759897084190029, -2.4145521341156786, -3.1778136512578987, -0.4705986351923219, -2.690735395951868, 1.8344550341398156, -4.631928673995896, -3.9648843342839206, -2.8338712361724, 0.3861358016805826, 1.0340881652847056, 0.5563648071111131, -2.519970125057961, -2.089265108997767, -3.200452542962856, -1.002605817510361, -4.643318881363193, -6.3356740260823745, -3.679016482856605, -0.4125552212717164, 3.112901507149431, -0.06419999864888418, -2.304467719989918, 0.6362747995442641, -2.1917244861549827, -1.754542066846027, -1.532597146910279, 0.16643965365630153, -4.9674348344316135}},{{{0.335511547780623, 0.6835956993373491, 0.6288620519690282, 0.5104269047193071, 0.3650093629650956, 0.6467092942693431, 0.4067812792382531, 0.49937187800534977, 0.9581652049293916, 0.522602479366467, 0.27672727229494104, 0.05624642779829425, 0.2104358006699861, 0.5431202338286879, 0.7965469580079053, 0.9999972762826008, 0.9338872357662987, 0.24733930788568378, 0.7021802647958014, 0.18949574966586713, 0.3168220765686464, 0.8227129804890788, 0.4805324668829697, 0.027222697697468552}, {0.9813105287880235, 0.13911728115172978, 0.8516704149139414, 0.5167957929781616, 0.6163011658229278, 0.49240798688238674}, {0.44488913567568833, 0.017423914972811753, 0.6581359608935362}, {0.9698055075159198, 0.16816186338074726, 0.9611774871745175, 0.4477001602235501, 0.42668527368723175, 0.3716149053728419, 0.9611802108919167, 0.5138129244572514, 0.17934596580154796, 0.6694346405770405, 0.7716844612260496, 0.19699084788860496, 0.3566329853124691, 0.18890217369407086, 0.7444617635285811, 0.21568031910058152, 0.21751570416073934, 0.33723175878012945, 0.2276659705504195, 0.5993791532776537, 0.7251077172783527, 0.8923426231044411, 0.21024205557760775, 0.9412431923841175, 0.7553022097624329, 0.7241807597236939, 0.24906456840309024, 0.4935430321605674, 0.32861693607520115, 0.35256585435085197}, {0.2878843575111735, 0.979730107703316, 0.14927097027365316, 0.6831312137738115, 0.516199896285124, 0.782739259814711, 0.7926379849611841, 0.49422904007974056, 0.7717381327565429, 0.5670589407141295, 0.5751222808004447, 0.1569972812996111, 0.5440721622061234, 0.9676797874364759, 0.8500145635220921, 0.26465465819517, 0.33383010662851564, 0.026436595052358347, 0.0947123537596592, 0.5404738984714761, 0.0847655382254254, 0.5328935628917909, 0.766095417684458, 0.1879080441206241, 0.7968811807142518, 0.553163455188475, 0.6168244474108049, 0.5047768303468126, 0.28068128442912793, 0.7704241953737639}, {0.8241864624496208, 0.010547790267072107, 0.5089431516725851, 0.20336525465963445, 0.24906418164917613, 0.853550508967461, 0.9648709894664617, 0.2356854672231586, 0.399049618127084, 0.588895850772291, 0.631040882837946, 0.20924887217080027, 0.3043372643674248, 0.048421952300815, 0.5462753446125206}, {0.6763553092790093, 0.5382418466829668, 0.8605139081801909, 0.7493941638982687, 0.12319185409053433}, {{2, 2, 2}, {0, 1, 0}, {1, 0, 3}, {1, 2, 2}, {0, 0, 2}, {3, 0, 2}, {3, 1, 1}, {2, 0, 1}}, 0.9214173992721619, 0.35573707783337827, 0.4687128794691408, 0.3527676587167704, 0.0972309368225411, 0.3451892875663061, 0.9597697277965558, 0.14940240405713595, 0.8481667551733649}, {-6.171447031680062, 0.04144414198516638, -2.7352746464520274, -1.289178392514757, -2.75635856851604, -7.9797607071032, -2.2537826204599165, -2.4515819625657027, -1.2386425323991292, -4.879709110614364, -9.463045900146094, -1.300568455704042, -2.166060753180132, -0.6761502313986514, -5.44964493141363, -2.0739746805235493, -0.09976580854548311, -0.9244399332356912, -0.39066350460018495, -1.4520106253809981, -9.512348765517256, -1.596967544938634, -1.2089952497018015, -2.153365339801395, -5.476662317513443, -5.473874038080482, -1.0153795172640838, -1.1827056545278254, -1.019137270104598, -3.0312113985175353}},{{{0.49163877859884514, 0.9948987383300941, 0.9137169368339774, 0.449117137046281, 0.9027429278265541, 0.36385785549214816, 0.704468064663177, 0.14477987267885614, 0.854320975525739, 0.8175825108796275, 0.028112755384167767, 0.6065380259958894, 0.9938070673455481, 0.06818834698135882, 0.9049209012936335, 0.6851206267237274, 0.63806998951217, 0.599475467512218, 0.552153242576863, 0.5878896899011863, 0.2928807019458638, 0.6397057397156622, 0.4027508385197271, 0.7397229347278214}, {0.8012419233470187, 0.6448070013855681, 0.48903390168574973, 0.2906057976815404, 0.8984989955204646, 0.28094914589342}, {0.7845658370225727, 0.14582592500268426, 0.04417801999472552}, {0.46336663501379244, 0.756453081638405, 0.5392878990067949, 0.05037095264917736, 0.3951782880324336, 0.8515321803447715, 0.8541672722830674, 0.4123009631370074, 0.7957028205202156, 0.29937893776790847, 0.26627758238188115, 0.11942026119114366, 0.15599708080455332, 0.8966280992481813, 0.5265546476540598, 0.31817833784412497, 0.5111900794189852, 0.4075941975624316, 0.2359488499725194, 0.4196793423236604, 0.23024093352556518, 0.6230283605398589, 0.09012292496983512, 0.37550132232893485, 0.7668742985117727, 0.866575278901454, 0.5508350259630402, 0.3251303696797575, 0.3716960104793391, 0.015043098556682542}, {0.6966677536799728, 0.91282940654275, 0.5759931899591235, 0.715664160788774, 0.43039017129809165, 0.7934091453516064, 0.4199961091545702, 0.8190360615405927, 0.9038355236440319, 0.4752308075074814, 0.908806029735585, 0.4114418639781611, 0.6678866736715124, 0.055551465183821036, 0.6785650962100198, 0.7884135034383022, 0.5777637487016773, 0.6800501428548862, 0.9116907976982471, 0.9218382245368482, 0.02692872273863713, 0.3549197731751287, 0.539994787218908, 0.9067951259801657, 0.33026096905866437, 0.4420903666323786, 0.9640015972597845, 0.19113096519139153, 0.8998707977605728, 0.6486812212807722}, {0.5440054881052143, 0.3720949036507988, 0.9960352741165409, 0.17345041377329073, 0.6351994583696293, 0.9606530396726377, 0.3281486004450284, 0.11789894858946971, 0.9566343621596095, 0.1722395362343355, 0.750384851743351, 0.4378488057345835, 0.04494356446136236, 0.25040131169748736, 0.7234561290047139}, {0.08292903255945487, 0.5049487772424543, 0.34360618571732177, 0.39319515994604953, 0.6408386659270763}, {{0, 2, 3}, {3, 0, 1}, {0, 2, 3}, {2, 1, 3}, {0, 1, 4}, {2, 2, 0}, {0, 0, 3}, {0, 1, 4}}, 0.5409471799826698, 0.15247522052593024, 0.4933243621854768, 0.9921574446463041, 0.9969416918774556, 0.7803803168751314, 0.4972890880689359, 0.8187070308730133, 0.3617422335078263}, {-7.038528287425631, -3.9183481284682258, -5.455141419171335, 0.8201850865350591, -5.178356759454903, -11.371786608934784, -6.097858019823525, -5.989270108047912, -3.059633519428341, -6.40677026979537, -2.310874599768824, 0.2811604943007464, 0.6745573914992362, -4.517453701458094, -1.2780092733733768, -8.060991075250904, -3.7107254840929844, -4.573235519182426, -1.3917231267417232, -5.210462809007293, -7.888942263007654, -4.442601630575947, -3.7691898029959594, -0.12497631278623333, -7.187648104046884, -9.849102132584697, -2.918282184023275, -5.793447297363311, -1.009260005208544, -3.928731872366949}},{{{0.8197272772024937, 0.16914048762390752, 0.7008080822835436, 0.40510787134821685, 0.6474877409681583, 0.4187556358805565, 0.2629592765489601, 0.36016430688685447, 0.3970864292706709, 0.6952995068758425, 0.18003024398950523, 0.8552155296444001, 0.053480243553349155, 0.302104346929793, 0.5391915780624289, 0.31426834966173023, 0.9010050230274189, 0.8087799847443162, 0.5470341334161248, 0.31732665778427466, 0.12062470615228746, 0.31149089667538027, 0.7283271025431115, 0.9555844242764484}, {0.3008974289497937, 0.14235040905147275, 0.027519020259567848, 0.5504765529282315, 0.6534096879816355, 0.7235947731709163}, {0.7645597437106078, 0.19031224604137706, 0.2563232587109645}, {0.028295266295073736, 0.5845294997211025, 0.33509671639697697, 0.20284301515761535, 0.7261909193652808, 0.045337921658673556, 0.020828366735246722, 0.30183799213019646, 0.9174109346209646, 0.49830378824254873, 0.7035017089509721, 0.18121328597790898, 0.6059200379455842, 0.7699766856994372, 0.7479172846745237, 0.8803158570281153, 0.4635696288941115, 0.7424576654398694, 0.1974407317462922, 0.22690616904647987, 0.7399748557231952, 0.9778979217292616, 0.007128485704915141, 0.9705829103355154, 0.7116795894281215, 0.39336842200815914, 0.6720317693079382, 0.7677398951779, 0.9854886700628408, 0.34803050034948557}, {0.6512034025726915, 0.46590190304770357, 0.06807773544187623, 0.8497267121069368, 0.9477016936217194, 0.2846886170697946, 0.46215769749629193, 0.07975002640749963, 0.19978440894719568, 0.40437276004167927, 0.9985880686021804, 0.33729236096763027, 0.002343677200903476, 0.17746659099519943, 0.25861321287898514, 0.3593944392383686, 0.9952151914959884, 0.20688368065968407, 0.5469336234508636, 0.9660260172302095, 0.32318342218805013, 0.43914378548178407, 0.5614449533880229, 0.617995516880724, 0.6719800196153587, 0.9732418824340805, 0.49336721794614663, 0.7682688047737871, 0.7242783259936393, 0.688553265364286}, {0.031209520449854696, 0.6885187783662875, 0.5244939170464437, 0.28418050532260664, 0.03262145184767429, 0.35122641739865723, 0.5221502398455401, 0.10671391432740722, 0.7740082389686891, 0.9918319781602886, 0.5269350483495518, 0.8998302336677232, 0.2270746155178255, 0.02580596093007907, 0.20375162616150166}, {0.46068644818593907, 0.6656296621298027, 0.4078104440493551, 0.531771606546143, 0.48744456575185857}, {{0, 1, 1}, {3, 2, 0}, {0, 1, 4}, {1, 2, 3}, {0, 2, 2}, {2, 0, 0}, {3, 0, 0}, {1, 2, 0}}, 0.172262444183656, 0.6395416392755681, 0.8074932805525037, 0.7988913003875726, 0.1410529237338013, 0.9510228609092806, 0.2829993635060601, 0.514710795064966, 0.10843147188612702}, {9.724458197022734, -2.8797901172423432, 4.516340325046723, 5.271722236521437, 0.8759485581085364, 10.76444884004628, 8.909428613007293, 6.841491648482505, -0.9994235735542437, 4.765373131904229, 2.5082119435920136, 1.9499077057514107, 0.1917137452284432, -0.6264177893078648, 0.904979245347513, -0.8557244461335456, 0.9987821107706552, 0.6070271155067726, 6.132694817889421, 6.887851235672631, 1.1152018921324531, -6.157004186654829, 9.473634507120117, -3.0246063587827763, 1.788252764930621, 5.1711618047560055, -12.195078207179561, -4.971961991192965, -5.002893122174636, 5.140733171629199}},{{{0.5997964435106233, 0.7608491236605199, 0.4079968807375588, 0.33442323291743786, 0.6079644653503348, 0.23391407531096817, 0.5081666470698356, 0.10734861739961238, 0.5821585044202556, 0.030162449149466513, 0.04748019888389653, 0.44171895526980975, 0.17434806037090056, 0.4983908426033235, 0.560035633132038, 0.26945651108615376, 0.5348064210953325, 0.6908975620508199, 0.7611443327444652, 0.12840358735235244, 0.583783560186052, 0.4078981985447597, 0.24643353767949927, 0.01997211546622541}, {0.9839871166754287, 0.6470490748842398, 0.8384366569419405, 0.6855488825487875, 0.37602265132509394, 0.4131349995732716}, {0.33027000987210486, 0.5782002651491751, 0.7938641469048383}, {0.38297255042380507, 0.2827898109882083, 0.1364813098793654, 0.6195160865339377, 0.8845817078204815, 0.7227541778561704, 0.8670247987932117, 0.08470966543860517, 0.19368414576966173, 0.9616098451117051, 0.7386212114408592, 0.5009261052525532, 0.785785947224902, 0.7151763074322058, 0.7186490959746339, 0.5169389885771245, 0.13873687234066223, 0.8767396504902654, 0.03310021342584631, 0.1409163372520305, 0.7256018727673906, 0.5464696406181605, 0.4548999482766712, 0.34705219034719226, 0.34262932234358556, 0.2636798296299521, 0.3184186383973057, 0.7275361038132545, 0.458047614523104, 0.5409256517737817}, {0.45139383960409407, 0.6428264383746494, 0.26436346875344224, 0.5793158066620766, 0.7127726281632348, 0.14190033312209618, 0.4785775215285403, 0.8641394992298708, 0.994123532188601, 0.6249613445449718, 0.33984064918787804, 0.9873998487396054, 0.9610233187627546, 0.4840450072929412, 0.6142387764204874, 0.440930208121445, 0.5061233704860835, 0.13699281694574894, 0.27160945407690185, 0.1772503784914929, 0.18770473208877775, 0.40945671313249443, 0.8135618395537979, 0.6363247267177112, 0.7363108924846837, 0.7666302747578451, 0.5491983708003556, 0.05700892005563458, 0.023538264321448878, 0.6247299416357489}, {0.07062084927181535, 0.1928694208257638, 0.029414732132847926, 0.9997685970907771, 0.7307802000839373, 0.20546957208615835, 0.06839141337009329, 0.515723589797836, 0.11654142366344994, 0.7645393639647133, 0.5622680428840098, 0.37873077285208706, 0.8449319695865481, 0.5872889854732205, 0.3745633107952321}, {0.9692740597195927, 0.03137013003275024, 0.9509642587555093, 0.6382524183105484, 0.20264378496174756}, {{1, 2, 1}, {1, 0, 3}, {2, 0, 3}, {1, 1, 0}, {2, 1, 2}, {3, 1, 0}, {1, 1, 0}, {1, 0, 2}}, 0.48217175923239464, 0.8939553386998748, 0.6147141539890996, 0.5779138433259987, 0.4115509099605793, 0.7010859178741109, 0.5852994218562516, 0.5781452462352215, 0.680770709876642}, {-0.656223223333939, 0.5613673893335245, -2.225613347917627, -1.6822716898914423, -6.994380516737782, -1.5471029591333183, -1.568575782663543, 0.6578716017896142, -0.4573671879667116, -7.329099597280891, -3.175076654950153, -0.5159587194464623, -4.880824241693749, -4.481691519575871, -9.375839007874006, -0.23273759035204522, 1.345077628779061, -2.7842906586622895, 1.057451608583179, -1.7699190928519608, -1.3181629725045398, -0.3608699237241987, -0.4398152896158586, -0.6326633567845772, -4.512307912595311, 0.1859320313851749, 0.964817760017285, -4.363499454771039, -0.3629886109530993, -4.4798291304441475}},{{{0.49561634578795255, 0.5169080084861583, 0.06242165643738547, 0.564229286213192, 0.7310769818232392, 0.9546399656021485, 0.6836908835852984, 0.719297316626644, 0.14378799635001874, 0.5800766548069164, 0.7144168238657058, 0.6879271865938937, 0.19282373759450944, 0.941824236496368, 0.5117730389039582, 0.20575542736149904, 0.29886839889463473, 0.32711008250726853, 0.9338591955779596, 0.7942045174009198, 0.5977824810205238, 0.7418106606510169, 0.3557139493427381, 0.11343380752427777}, {0.10216613523257126, 0.2249026521648586, 0.29329229290535264, 0.5492045213110858, 0.3710891534093321, 0.27026268656271013}, {0.6096014093200542, 0.8299072046844418, 0.22730115705931334}, {0.6901860317557937, 0.8951845854543484, 0.1419800180905481, 0.0344774194648039, 0.7483617952594257, 0.3834115465503902, 0.9362245907290491, 0.7356090205701692, 0.42125171275215717, 0.4495523509724307, 0.14202007332812933, 0.13782653954964538, 0.6794410521011403, 0.09383840162969256, 0.02858626580385155, 0.035660404317074124, 0.45453839993628165, 0.80054610872434, 0.4793817444927658, 0.664571250907742, 0.18427571337357154, 0.1909446994042857, 0.649474539808324, 0.43727009384842874, 0.49408968161777783, 0.29576011394993723, 0.5074945217177759, 0.4027926743836248, 0.7457278863583522, 0.9123485673995471}, {0.5712699309887268, 0.6671836538134557, 0.324476173606195, 0.4627962164271164, 0.4292498576605975, 0.5293571142638103, 0.6450351215050547, 0.3689578147974238, 0.40066359185674594, 0.49369670994673615, 0.1904967215687731, 0.5684117060730839, 0.9212818473639801, 0.829125459038994, 0.0062210081952015625, 0.3774670066687982, 0.27180730755565613, 0.39185536519056535, 0.5121313265774237, 0.08170689271886092, 0.7643127858378802, 0.9890626908069405, 0.7664034402190716, 0.16935832531931388, 0.19304285484915343, 0.32187903699348486, 0.4419272666128765, 0.7065621088921975, 0.763792997188556, 0.7925219227296746}, {0.7968921451078218, 0.3376042940947737, 0.36312940533181, 0.29882521278293844, 0.6063954235390487, 0.7691925880216899, 0.4418475579678299, 0.46969975374394435, 0.6001744153438471, 0.3917255813528917, 0.17004025041217377, 0.07784438855337898, 0.0880430887664234, 0.31001868863403076, 0.40572746457429354}, {0.08878169774643846, 0.3216396485473519, 0.14066036331471687, 0.2126846097251401, 0.7669026607529535}, {{0, 2, 1}, {3, 2, 0}, {0, 2, 4}, {1, 1, 2}, {3, 0, 3}, {2, 2, 4}, {0, 0, 4}, {1, 0, 1}}, 0.8797123819344753, 0.43409825442251937, 0.44889161253658416, 0.974380738023279, 0.08282023682665354, 0.09649396032774563, 0.08576220720477416, 0.6755555252403406, 0.47642481328760483}, {-86.09292866783345, -110.59348890115031, -8.585095371821918, 5.5080182268131255, -93.1140736210246, -44.46306744064242, -116.23277943081267, -89.22929450797191, -47.457081054223785, -52.08584561626012, -10.561011543274105, -7.613797804937912, -80.78146416646244, -1.5906306637899756, 5.5692462936274065, 5.005241290886846, -50.19465384112157, -96.97451631715673, -53.7019836058271, -80.11571396650264, -18.27081474500965, -14.91805351642644, -77.2893256093019, -50.72814317885474, -59.375533465076195, -34.49754741494521, -59.33453449789751, -44.46831261455971, -93.07135516096257, -114.69835034537488}},{{{0.32730137230605577, 0.6439146492369443, 0.2058557714963962, 0.8762503979437577, 0.9355757909531641, 0.4738743988247705, 0.12801138294301723, 0.7882073091773343, 0.6255571023191333, 0.06814693425047699, 0.039229685196578754, 0.46656766062998245, 0.48489673900441643, 0.8554623245253369, 0.27232702444362517, 0.5868552786955071, 0.05079848458189709, 0.4065707119887527, 0.2979462864203462, 0.5040350418688536, 0.9543045242541515, 0.32080850478397854, 0.6223907611800057, 0.027610228581248744}, {0.6270031519480957, 0.6768938555470343, 0.4165349896836094, 0.151359830637491, 0.6914273609949316, 0.20301945672226376}, {0.28852360674059224, 0.3631525214601567, 0.06587025867579831}, {0.13487252247178677, 0.24929392154401347, 0.8965848608301742, 0.5809735196713819, 0.2794101979464499, 0.9769668971003883, 0.30972958213466706, 0.5301750350894848, 0.8728394859576972, 0.6790206106800422, 0.8056945402658134, 0.5758705108353334, 0.5520309811737186, 0.05662984950003648, 0.7780843116845647, 0.9488673588872376, 0.8751371256266843, 0.640094859816427, 0.6267244810470737, 0.257439997892306, 0.6721176689044206, 0.3515712530758348, 0.26357195958691704, 0.19156973921650766, 0.5372451464326338, 0.10227733153182134, 0.36698709875674285, 0.6105962195451258, 0.25783494848618393, 0.12531043443143303}, {0.05725751662207574, 0.08042118445564102, 0.38499546252848676, 0.4462898237513909, 0.25156297635626224, 0.5045506736203077, 0.8329644813547681, 0.38965997425135446, 0.4734786646716975, 0.5556833147330701, 0.9578273557280838, 0.7495651144349275, 0.8467541836246238, 0.2982433168407641, 0.2857096868236632, 0.3979938613590926, 0.5831822240377068, 0.10667357762425644, 0.7484645403910294, 0.29571652982727126, 0.21619512528096393, 0.49607735807913067, 0.49062959190484545, 0.1704060953958382, 0.1589376086588882, 0.4156561736234896, 0.10563412937635867, 0.7241162716444473, 0.9073746323026259, 0.9111055000031819}, {0.27266964802159055, 0.33445629739309285, 0.4338959676309284, 0.3554221852701118, 0.31484229229350674, 0.5848911829581654, 0.5871417840063046, 0.05717886842934773, 0.029132605469843566, 0.18689732159907285, 0.003959559968597866, 0.9505052908050913, 0.2806680650788142, 0.8911807917718017, 0.7877644346876339}, {0.45442793272596066, 0.7900384731739688, 0.7207746963759634, 0.6288268260287457, 0.038771759102471014}, {{2, 1, 0}, {2, 1, 3}, {1, 2, 1}, {2, 1, 2}, {3, 0, 3}, {2, 0, 2}, {0, 2, 3}, {2, 2, 2}}, 0.6844043437976101, 0.9966584247315161, 0.7214521937261198, 0.12766625909928908, 0.4117346957760195, 0.6622021273384232, 0.2875562260951914, 0.7722440738291773, 0.09689240348251278}, {4.9138132117218385, 2.615656764143255, -3.375218850391235, 0.34370575860614894, 2.986472587557987, -5.879790873319984, 0.6707106398642384, 0.5599624335093003, -4.318919465895394, -3.839691987977651, -3.5284504886891965, -2.219285580697618, 0.5559362481465002, 5.778653584644001, -4.482728529011734, -5.080183355055387, -6.127854786346983, -0.9653328529389942, 0.1531013382639843, 2.3532833126346904, -0.9371810103606881, 2.22249027560893, 4.445485140603885, 5.054088450329821, 0.07825227574637372, 4.246752892632817, -0.6814033794374477, -0.28882531819438717, 4.206302464650711, 3.4301771475825227}},{{{0.0773109443802578, 0.7004144420888868, 0.7150652053998295, 0.06775979801266921, 0.890413622781185, 0.6964548821202889, 0.7645599145947383, 0.787091732933855, 0.9992328310093833, 0.9086904474326549, 0.31013198186877755, 0.9970532597598862, 0.27845813463341995, 0.27986362140390925, 0.27136022276630656, 0.3126489159622762, 0.2817997099019039, 0.5584114276777894, 0.14369396366701748, 0.9009142201862567, 0.6195975825634806, 0.27085520158259807, 0.3714498898378402, 0.8040218167037438}, {0.5422866381832229, 0.5704407594937113, 0.6563846844380107, 0.7362620186910747, 0.6518730154020379, 0.8739858773734224}, {0.8918247698432725, 0.9491702857572196, 0.6526401843926545}, {0.9652954299407674, 0.581692787974495, 0.9521170259973334, 0.3741820497592345, 0.6854318085368583, 0.3103325652081884, 0.6394681100350572, 0.09238233985733064, 0.12702038085906878, 0.16663860154117094, 0.7385538898488005, 0.47278475729385, 0.8561651792764707, 0.7951887117033307, 0.9345320731450567, 0.9304981191106272, 0.2857244197827594, 0.13880402726531996, 0.19827005445398202, 0.27862510370858934, 0.41173854240933705, 0.24697925742204746, 0.24909976869676237, 0.6259849193159348, 0.4464431124685696, 0.6652864694475525, 0.29698274269942904, 0.25180286955670034, 0.7610113039317113, 0.3549539042393641}, {0.6575146326643718, 0.15942052969936968, 0.6339909230726426, 0.1883153026981932, 0.9189607428155713, 0.6866357724055197, 0.7778257437961719, 0.3931265909948625, 0.9844286696705147, 0.7561376532948925, 0.49210132401341244, 0.25432256372954254, 0.7861586152165326, 0.4775125495863031, 0.08036278160407542, 0.00734330630749507, 0.5370588465197702, 0.8515276302703683, 0.6339196691355058, 0.34205683685994254, 0.24007610382034122, 0.599724760713668, 0.8729083652037944, 0.9871029326205785, 0.5825614711559693, 0.4403042310142983, 0.23891744213115182, 0.7987876299223853, 0.6636007283403981, 0.7536684586087786}, {0.4610916983349799, 0.40566103892752275, 0.6791720586698834, 0.9975308053138862, 0.9689903743215674, 0.15133847519798022, 0.8930134434533509, 0.520018255727583, 0.888627592717492, 0.14399516889048514, 0.35595459693358056, 0.6684906254572147, 0.25470792358198624, 0.8019383320305425, 0.11587849311323936}, {0.0687658647435467, 0.3817995583781918, 0.8148353994099642, 0.5333170219572699, 0.6284616337292485}, {{2, 1, 1}, {1, 0, 4}, {1, 1, 1}, {0, 0, 2}, {3, 0, 1}, {0, 0, 3}, {0, 0, 0}, {0, 2, 4}}, 0.14288211624703998, 0.016047769487578908, 0.8697162936168719, 0.8747931751204698, 0.6817904179120601, 0.6103867305600562, 0.19054423494698844, 0.8772623698065837, 0.7128000435904925}, {-14.091650218625933, -3.923158802575103, -15.505702758900526, -4.806326294726651, -6.417661345275885, -0.9594673234062663, -8.366347646018156, -0.6728725793446184, -8.89910569021444, -2.821106665282727, -7.715916049792786, -0.0983319565438614, -12.3107724418952, -15.566959876641924, -18.77738960036411, -13.397208014608026, 6.088803255706251, 6.719245773090457, 0.17214959651476924, 3.0400645608508188, -3.07067338538167, 2.4462810616095423, 0.10964443704033577, -16.698493733980538, -10.014139245189169, -9.149022250758819, 1.0254637797461106, 0.2256890069081381, -21.03995834578557, -3.5141869220644306}},{{{0.45904825536207594, 0.2975307914936376, 0.35724411407900075, 0.8241724508730005, 0.3150530864715908, 0.941576194560057, 0.6887534886217861, 0.5694645272910143, 0.5131147544410483, 0.8256977014468176, 0.6199876238782394, 0.1876649689128225, 0.6982793550310841, 0.2923806794895477, 0.9915259901489909, 0.044782852665782524, 0.6822315855435052, 0.42266438587267585, 0.1167328150285211, 0.3629924347537225, 0.07184485498344899, 0.23212015092568739, 0.2394704452219374, 0.6501923911632299}, {0.612796599621373, 0.9345893594320498, 0.8822263311429366, 0.8260199402902294, 0.29774351314978226, 0.9930131648719928}, {0.19347284252115057, 0.2565554129992151, 0.784628758708734}, {0.16731546342517506, 0.5734852186429112, 0.0688904440863926, 0.08634940367764996, 0.8749347839356274, 0.5819592284939202, 0.024107591420610072, 0.4041178181341448, 0.4522703980629515, 0.46522641346539917, 0.6611151566668876, 0.3322729631506958, 0.22015024713726414, 0.22575596824346178, 0.010922765503657676, 0.7194763635293228, 0.2855608877052144, 0.34352963710052514, 0.1849028252134283, 0.4217328503795405, 0.2925477228332216, 0.15005679457937457, 0.9283474122142131, 0.6371040916708065, 0.12523225940804655, 0.5765715759364634, 0.8594569681278206, 0.5507546879931565, 0.2502974754724192, 0.9946123474425431}, {0.8353493767072105, 0.14663686985901175, 0.7980270774094677, 0.529385933977144, 0.17423422004032293, 0.8143639067083159, 0.5778768302722035, 0.30362996573368217, 0.16331145453666526, 0.09488754317899317, 0.2923159425669892, 0.9601003286331571, 0.978408629323237, 0.6731546927994526, 0.9997682197337676, 0.8100435340537825, 0.05006121710902379, 0.03605060112864616, 0.874535960325721, 0.23347195811731908, 0.1906042489812032, 0.48529591313548964, 0.6242384848533018, 0.23885961067477596, 0.35525487227399266, 0.3386590432764779, 0.8262114074438341, 0.7094736766976321, 0.18102065223366975, 0.524295136568162}, {0.24833457717163063, 0.40584371096394983, 0.017709197697004506, 0.4294075933891688, 0.9560186346046414, 0.4457433823307928, 0.03930056837376753, 0.7562529005897161, 0.9562504148708738, 0.6356998482770103, 0.9892393512647437, 0.72020229946107, 0.08171445454515282, 0.40222789015969124, 0.7986351022835405}, {0.23490638632558034, 0.457475969691851, 0.1633682794849153, 0.44338023000954785, 0.8962473430491025}, {{1, 1, 4}, {1, 2, 2}, {0, 0, 3}, {2, 2, 3}, {1, 2, 3}, {2, 1, 1}, {0, 1, 0}, {1, 0, 1}}, 0.6312645622480169, 0.4538946027872833, 0.2623595777758781, 0.3719522064809405, 0.3829299850763862, 0.04805089182333344, 0.2446503800788736, 0.9425446130917717, 0.4269113504717448}, {-10.46828578559993, -14.622827739003714, -1.946054413112132, -2.8434235447873037, -22.212162763623738, -11.954754053405985, -1.1720213144108234, -7.617052989511393, -8.977323041339885, -11.237330146960813, -22.771498777061673, -11.809571537368445, -6.861256167324246, -7.9597956776418695, -11.559333775870334, -18.45590277848124, -9.181264975625627, -6.99308091462804, -4.141686029349976, -14.735403179223294, -9.623516307518228, -4.884195584166644, -16.30422655903346, -12.277381065265292, -6.770004844121033, -12.954522810805866, -15.657371037785751, -10.638467001844601, -6.0201112564969925, -20.930592149898324}},{{{0.6023075094925406, 0.20534981170510608, 0.18629171250205562, 0.4706609356008709, 0.9666076612155303, 0.2161104604403623, 0.46608941304098567, 0.38894648105571805, 0.564379771055839, 0.4174753581568218, 0.23118302671540536, 0.931470511363867, 0.40101149157092375, 0.974095128147274, 0.3349356836663029, 0.30020594911585025, 0.9471168887836404, 0.7117355503713958, 0.9629834771853624, 0.9172759640394641, 0.899065996960307, 0.46708517029252217, 0.020438864093590647, 0.4903646135677193}, {0.2967584874677664, 0.26173535858741614, 0.834147151591535, 0.01970367796684843, 0.3301508262522361, 0.045624898147053804}, {0.36805773855054935, 0.6307571969111304, 0.765771055196397}, {0.628149539990232, 0.136874711835144, 0.6992866855472633, 0.3647595636254733, 0.6540544118429581, 0.8019390281688411, 0.399080736431413, 0.4176426748418328, 0.9423188614715623, 0.8389555509834787, 0.4818047723919489, 0.5185766778815258, 0.47523369117904013, 0.8185166868898881, 0.9914401588242296, 0.22181819041375944, 0.213498332591624, 0.984369535298353, 0.9717364808573812, 0.8916673641615234, 0.1678734344445702, 0.6163117967478037, 0.3409792839462508, 0.12589630896512632, 0.5397238944543382, 0.47943708491265974, 0.6416925983989875, 0.761136745339653, 0.88566948261138, 0.6774980567438186}, {0.24261186196757453, 0.3434940704978202, 0.9433506211398177, 0.83854250576034, 0.7608070895756256, 0.8249173926162944, 0.4681169299607776, 0.02002581887045184, 0.7693669307513961, 0.603099202202535, 0.25461859736915354, 0.035656283572098796, 0.7976304498940149, 0.7114318380410116, 0.08674516292458335, 0.4193444868242951, 0.45665116594776406, 0.5855355290758852, 0.5470212684702452, 0.9399074019116354, 0.8149585675487765, 0.8243987837362322, 0.6613517858588651, 0.2624093451678168, 0.572346705581202, 0.48090471323841205, 0.7180011647190474, 0.4238668394074769, 0.8115396160055764, 0.6559873206221176}, {0.24988423475826985, 0.40384102053702503, 0.04217268525418038, 0.052888118419582686, 0.9952656373891163, 0.3681847369649262, 0.24454223536016553, 0.3414562803785711, 0.908520474464533, 0.9488402501406311, 0.7878910694124015, 0.7559207513026859, 0.36149920599428775, 0.008932848228995757, 0.9729325018636249}, {0.9315219675664536, 0.7001474201354226, 0.746523503061179, 0.4005857962824229, 0.45061725432804156}, {{1, 2, 3}, {0, 1, 0}, {0, 0, 0}, {0, 0, 4}, {0, 0, 0}, {1, 1, 1}, {0, 2, 1}, {1, 1, 1}}, 0.9821462554163752, 0.32265666365370216, 0.5890461802768465, 0.7946299337059239, 0.7322620206581053, 0.9188156431166771, 0.5468734950226661, 0.7417418152863412, 0.7369963832689891}, {-3.2940718782414673, -0.6668873143393355, -1.8988201956355069, -0.9115349521981753, -7.1688734914947005, -3.5697221856910293, -1.9564983135578966, -1.329592679220157, -4.351727933519763, -10.427525933190134, -0.7436519154890194, -1.0534426715114988, 0.16484131227860951, -0.4374308244060404, -4.573230915115689, -1.5395675489705054, -0.625863819596125, -2.903402104085383, -3.875710343559228, -8.706856191625022, -3.2085779472583136, -3.439925396648892, -3.0183804791768356, -4.936737288548317, -17.472195860231174, -6.039474233751853, -3.575153082884722, -4.577647246570575, -7.247186221944171, -14.565872544066465}}};

  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float dloga[6 * 4];
      float dgamma[6];
      float dlogbeta[3];
      float dc[6 * 5];
      float dd[6 * 5];

      ParameterizedNormalDistribution prior_loga = 
        parameterized_normal_distribution (data[i].inputs.logastddev);
      NormalDistribution prior_gamma = 
        normal_distribution (data[i].inputs.gammamean,
                             data[i].inputs.gammastddev);
      NormalDistribution prior_logbeta = 
        normal_distribution (data[i].inputs.logbetamean, 
                             data[i].inputs.logbetastddev);
      NormalDistribution prior_c = 
        normal_distribution (data[i].inputs.cmean, 
                             data[i].inputs.cstddev);
      NormalDistribution prior_d = 
        normal_distribution (data[i].inputs.dmean, 
                             data[i].inputs.dstddev);

      dqfunc (dloga,
              dgamma,
              dlogbeta,
              dc,
              dd,
              data[i].inputs.loga,
              4,
              6,
              data[i].inputs.gamma,
              data[i].inputs.logbeta,
              3,
              data[i].inputs.c,
              5,
              data[i].inputs.d,
              data[i].inputs.pz,
//              data[i].inputs.priorz,
              data[i].inputs.ratings,
              8,
              &prior_loga.base,
              &prior_gamma.base,
              &prior_logbeta.base,
              &prior_c.base,
              &prior_d.base);

      for (unsigned int j = 0;
           j < sizeof (dc) / sizeof (dc[0]);
           ++j)
        {
          assert (fabs (dc[j] - data[i].desired_output[j]) <=
                  1e-3 * (1 + fabs (dc[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", dc[j], data[i].desired_output[j]),
                   0));
        }
    }
}

static void
test_dqfuncdd (void)
{
  DQFuncDCTestDatum data[] = 
    {{{{0.9746091993316685, 0.5056205734925442, 0.6102465099140325, 0.8030165324493407, 0.9097276465146787, 0.2715252626125114, 0.48487641357828554, 0.11750506999661521, 0.6944545114166508, 0.8449587799799826, 0.25825767293529134, 0.813572585606458, 0.4973716849434365, 0.353830210811877, 0.914754764812323, 0.9396472850242626, 0.725600546452472, 0.34208733550838377, 0.323440850303471, 0.49308063176509254, 0.2989481510344538, 0.45429200632168637, 0.18386668297082842, 0.717476389971643}, {0.3243389517027853, 0.9486714328291421, 0.5736201730567959, 0.9144598575223023, 0.41461130518810657, 0.6771461702166307}, {0.08874375947851038, 0.796954787525687, 0.7201567937714557}, {0.8321873902366481, 0.830486086543219, 0.983382201919229, 0.22278510882801925, 0.47835717942477113, 0.915731321730896, 0.043734916894966384, 0.4971845623755473, 0.13626984391638736, 0.592290471427425, 0.5506542851298739, 0.1982364113410935, 0.681977837594701, 0.4084237884565966, 0.8331778951582309, 0.8738974596383081, 0.7333064047655589, 0.8348036153998006, 0.9187180376359286, 0.4592861544502016, 0.05616023454892818, 0.7460598559212903, 0.12176325011024161, 0.7391293606787459, 0.2239728443122801, 0.9155737693780713, 0.13838104819101257, 0.5163442518507266, 0.745615664887509, 0.9998424476471752}, {0.0946461312960462, 0.019159689475179324, 0.6093458209711216, 0.40755197621975026, 0.5439918461661724, 0.8209232781340858, 0.9273679833764206, 0.9991281877631537, 0.7108139510079414, 0.9470258184957777, 0.19406157861086168, 0.16432457236335302, 0.7920959133720128, 0.48773966404557606, 0.13790134406193352, 0.4182647164420627, 0.6703326632617712, 0.7486103033668302, 0.9139284997496534, 0.5026909470639914, 0.5319516150707586, 0.2322660515161036, 0.16831283486214446, 0.5028484994168162, 0.4373054837747124, 0.21310636204092429, 0.5589670138910229, 0.09529652319706589, 0.8933136376085401, 0.3921830839068384}, {0.6315990305146023, 0.0961683354339122, 0.18249968660059862, 0.44515726541106077, 0.4375374519037406, 0.9318437630705592, 0.3904037732285858, 0.9574176013654847, 0.2996361078418071, 0.5135790466284965, 0.7200711099668147, 0.20880729799865447, 0.3857076080921537, 0.010888099564505075, 0.18811949489605606}, {0.9765412464825508, 0.21739477323000922, 0.5080396001476889, 0.7508140111213437, 0.7634348844416265}, {{1, 0, 3}, {0, 0, 0}, {3, 0, 4}, {3, 0, 3}, {0, 0, 1}, {1, 0, 1}, {1, 2, 4}, {1, 1, 0}}, 0.6584277593389863, 0.412743076950623, 0.8575003735128036, 0.3712518005347881, 0.02682872882438403, 0.31657474151671083, 0.6750006869122049, 0.9260945351237274, 0.5892912769206434}, {-4.173111177524225, -1.7296146909066064, 1.091781172980303, -1.6924979922591294, -3.813580989634322, -2.151199895826846, -2.7328895759259177, -0.09185749609050992, -2.149702782922673, -3.2257462533792927, -4.1839329125263385, -1.6831918066025264, 0.583138165363797, -1.815283874625677, -1.407942091153294, -7.658086739844853, -5.2213047572567, 0.8722813624964514, -4.04398918813161, -5.642127627581159, -1.876756478291302, 0.21882994101074726, 2.372043989671238, 0.6295071969180026, 0.36770624479218017, -4.562555752207533, -3.9769957949001027, 2.7448678559238973, -5.115635091163762, -4.517003635025196}},{{{0.3847309784461516, 0.28459691368361917, 0.9686769337582427, 0.2896551690788363, 0.8711519318176552, 0.5645258037168045, 0.7598696357595882, 0.9039475609866826, 0.8602638322531501, 0.37640630882074844, 0.7833283892770374, 0.6865527877566734, 0.3522242321054611, 0.6255922976994047, 0.01989350483541079, 0.02812502841768706, 0.9394811551548381, 0.7680919241866011, 0.6486417043006226, 0.0012962995933030283, 0.6229064136381273, 0.09309123727439617, 0.7225471691768953, 0.41200502267265965}, {0.23817543519197565, 0.808494323590777, 0.7538702354186526, 0.12234985359382333, 0.3670235033743205, 0.24396851987397253}, {0.9940005996590644, 0.21840229260714072, 0.5067596711211705}, {0.8675622110532241, 0.21067221038202705, 0.5318495048504673, 0.15453543901570932, 0.24196991335381934, 0.19077870554661627, 0.5037244764327803, 0.21505428386087122, 0.4738779891672182, 0.5421370012459936, 0.5024281768394773, 0.592147870222744, 0.380786751892822, 0.8195898320690983, 0.09042315416681762, 0.3539724350307683, 0.572292428302045, 0.06571959665044567, 0.9680733005729943, 0.9869489316564478, 0.32832390842807246, 0.07171899699138126, 0.7496710079658536, 0.4801892605352774, 0.4607616973748484, 0.8610467866093542, 0.21782150311538626, 0.32565382151956807, 0.21879178402102903, 0.6702680810627379}, {0.714097026682606, 0.11059953765869683, 0.7449137948538108, 0.12813107981674432, 0.21166884984312875, 0.5184516674359528, 0.36412704296098874, 0.308541247747646, 0.12124569567631113, 0.16447923240518453, 0.7918346146589438, 0.24282165109720033, 0.15317239510331684, 0.1775303007487367, 0.46351070623087126, 0.17110265410581907, 0.40350138713746325, 0.6973410402134593, 0.0027490088560228926, 0.31005586749646485, 0.18567988402207702, 0.3716872186938913, 0.7839572248349939, 0.6397877864337269, 0.47158285733947103, 0.2610876810351945, 0.03904342998118306, 0.5116567066169826, 0.2599140074963423, 0.7426360135992416}, {0.6749163870201943, 0.20311545886933657, 0.13866831182003117, 0.5781567811940571, 0.8830817723612505, 0.9602938077721362, 0.9854959167167143, 0.40062648044532034, 0.41957106613037926, 0.7891911536663172, 0.581994529579251, 0.703285440231861, 0.4168220572743564, 0.4791352861698523, 0.39631464555717405}, {0.3315982215379697, 0.6328648324393625, 0.8393474997361253, 0.924731788217703, 0.07051054050277525}, {{3, 1, 0}, {1, 1, 3}, {2, 1, 0}, {2, 2, 2}, {1, 2, 0}, {3, 1, 2}, {2, 2, 2}, {3, 2, 3}}, 0.5938214024581795, 0.32769079311914273, 0.6648177807213607, 0.32787452690353364, 0.9189050154379852, 0.12457533424980619, 0.5261494689013295, 0.7497177457094766, 0.035823243076734616}, {23.667440087982577, 501.29548587199724, -2.7886558015172627, 480.55536859925496, 420.18263933124706, 173.25187824088616, 302.089727015491, 337.19764123194534, 487.94201960584456, 457.0555456047698, -40.02998857498945, 397.30587309917223, 458.41385110507673, 442.82873890017726, 224.46800153203623, 444.1290611387309, 271.71562590541544, 33.63146961284673, 580.0648795760469, 343.516575857918, 432.5136933915822, 298.01640240854607, -34.29332340163167, 82.83469690984317, 217.66518822709503, 375.16739805655294, 557.5249979060347, 175.58467131295146, 378.53217618717, 6.409580898442148}},{{{0.16428152647766994, 0.5406535521846152, 0.34909126526415624, 0.6162521769463554, 0.3750903728113528, 0.9586590226053642, 0.6458058250322952, 0.19943011967199897, 0.8959550866415005, 0.5623443770481902, 0.3142076034943255, 0.5665652872326364, 0.05660758690537517, 0.6376125888304871, 0.24369706299155025, 0.9727438847744571, 0.7289167937862324, 0.9727948081091264, 0.9158225360880167, 0.05383886933647188, 0.6043414595364263, 0.4466453392077969, 0.16610479037854003, 0.018015626259737266}, {0.4400599330587563, 0.9059917870231817, 0.8170135251143839, 0.4017634493133819, 0.06496956024740347, 0.9473327644178176}, {0.1712077000820886, 0.20233332964138295, 0.16901447360590294}, {0.38498838736962737, 0.8570000965877631, 0.6357680424087465, 0.11240688670052777, 0.7473757985391402, 0.6133030335962129, 0.6630241576342895, 0.38349009291429537, 0.7745809904300137, 0.6974804975081962, 0.6091852882978176, 0.7791486333778691, 0.32793565122221685, 0.5313757071296562, 0.5911696620380803, 0.33908870031911287, 0.4219438641990352, 0.7143621820152724, 0.18940621272469838, 0.2741191400717094, 0.4746110997812176, 0.5431544819331837, 0.9870728830833154, 0.10510466646580643, 0.08962271241159028, 0.6861543853454207, 0.35130484067456896, 0.9926977797652786, 0.34224691387245004, 0.07285135174920784}, {0.6882806830402795, 0.6092076868509833, 0.5676659234424363, 0.37537085424101163, 0.07909539474246194, 0.8300590534731142, 0.23973027222021948, 0.8439951471113555, 0.48792573270438166, 0.4909703531540013, 0.8177864080211843, 0.12963296509608313, 0.2985195199796833, 0.2168512130822919, 0.34317530823996667, 0.5864784831628994, 0.3114466368963678, 0.11174654661648548, 0.2535525958283764, 0.9003240978174787, 0.9601417962217988, 0.11904876685120681, 0.9113056819559263, 0.8274727460682708, 0.2718611131815194, 0.5098410800002235, 0.34363975851349, 0.4521018918272592, 0.19276571843905743, 0.6797820265271094}, {0.10390948629327054, 0.6081067447159038, 0.7048399857346758, 0.18881167337310803, 0.2861230782720862, 0.4784737796198206, 0.40632046575499253, 0.9719604602908161, 0.9429477700321195, 0.8919952964569212, 0.0948738288586247, 0.8602139136743306, 0.6893951742037431, 0.9916711986394425, 0.13473203263682582}, {0.7411651468231238, 0.7780894922478168, 0.1641984525711717, 0.8628709194553065, 0.2313240668229003}, {{3, 1, 2}, {3, 1, 2}, {0, 1, 3}, {1, 2, 2}, {0, 0, 3}, {2, 0, 1}, {3, 2, 3}, {3, 1, 4}}, 0.43444973373432677, 0.7120965607439125, 0.670105201016249, 0.5515420402957909, 0.33054024744105626, 0.10398981602800876, 0.9652652152815732, 0.3627303669226829, 0.04441716916897002}, {-164.73957318043202, -123.53942736629462, -113.25489952462101, -12.554390655306715, 141.0761136701029, -236.5199702383692, 63.50874757684262, -250.0706322973586, -68.70957404551345, -66.06173175228692, -230.26663765468103, 120.20127929595913, 22.475787531435095, 69.09052744559274, 8.12991952125649, -113.23534065434752, 25.673148468631485, 123.48787455935017, 49.86296291395004, -274.044989576697, -302.7120817646172, 122.83373593319361, -280.636909138106, -240.94880978239613, 44.523788146720264, -74.37997916668725, 9.144355966607055, -48.46794414435523, 77.92558715754585, -162.03461146536782}},{{{0.6255160364081882, 0.5589447495265807, 0.3907699066318668, 0.10146939913685048, 0.733520739951267, 0.46407092066795597, 0.5305559929575362, 0.41207422493310736, 0.7418495413118243, 0.32933888803113015, 0.7893908461344123, 0.6339847326852905, 0.5776510887406527, 0.4664679685758237, 0.558066779311512, 0.19953499895096377, 0.8655545279967403, 0.7963627675595747, 0.00652473901572109, 0.8689947515099076, 0.7615647119687314, 0.8310975522780015, 0.6437943720930381, 0.8245775823409375}, {0.1360486755605433, 0.27215280275142084, 0.25302446546117136, 0.723108183204087, 0.40252793560927635, 0.8080818820834649}, {0.7224684725036352, 0.3110339582709797, 0.6606783942974519}, {0.4787429940523347, 0.9330776263692229, 0.6770492255856891, 0.08302730555679926, 0.012275025476511048, 0.3750108470577108, 0.47751422663472537, 0.21747277756005903, 0.21591225791693636, 0.3684861080419897, 0.6085194751248179, 0.45590806559132757, 0.3848147056389349, 0.7246917359489515, 0.7839418927838803, 0.3198593900307843, 0.11266190288751404, 0.4716672704877802, 0.06083370957979326, 0.917331454421508, 0.30458002080404917, 0.749198797984145, 0.7497997513088136, 0.25665306012405603, 0.8258370267517144, 0.8161211716149221, 0.07275052572312445, 0.17362575456725676, 0.8135620012752034, 0.44111032455721133}, {0.5952362990883991, 0.9561529770071977, 0.597649743358267, 0.07262421651522159, 0.9867168239635813, 0.5002449114158701, 0.21283503771933215, 0.34793248056627, 0.20277493117970097, 0.18038552138508582, 0.10017313483181811, 0.8762652100784899, 0.1419412215999077, 0.26305406696357786, 0.795593114027769, 0.12706641209434488, 0.39214147029109414, 0.0064010068395218495, 0.9697560872760546, 0.3109452404794228, 0.3193909445679697, 0.8327752522722651, 0.15619408600085113, 0.8698349159222115, 0.7241546454795706, 0.8766222752650674, 0.5585443426425841, 0.7972106994069899, 0.7374378215159894, 0.37637736384919723}, {0.34570930492325197, 0.44927821884071983, 0.5346628903362883, 0.19599184246411144, 0.24553617009143386, 0.5730130087622299, 0.3927216687363806, 0.9329377755005336, 0.4499430560636649, 0.4459465966678851, 0.000580198445286476, 0.9265367686610118, 0.48018696878761036, 0.13500135618846232, 0.6811892538773168}, {0.09376151638874664, 0.32399288278675925, 0.26516644026625086, 0.9570346083977462, 0.21713924112367924}, {{2, 2, 3}, {3, 2, 1}, {3, 1, 3}, {3, 1, 2}, {0, 1, 0}, {2, 0, 2}, {2, 1, 3}, {1, 0, 3}}, 0.7654485401441751, 0.46795574085926095, 0.21959678688175688, 0.840761877274482, 0.41973923522092316, 0.018677522018541136, 0.6849338965454685, 0.6447700348103705, 0.17420306512948933}, {-0.27171481641598594, -10.868156749361326, -0.9670922451477337, 6.923945116687774, -11.12660131181617, 3.804809180268643, 12.523371262050349, 6.933236787296321, 6.459852313946197, 15.439440621318584, 16.480335277323753, -10.877170700767682, 11.764744155812185, -1.0567601599861316, -4.708814943257508, 16.39068625461977, 4.573144735927542, 18.78019702266904, -19.798841337647808, 11.105411431742334, 7.992300091087156, -9.595962009643376, 11.800921833723084, -28.072512300552408, -2.385296488452905, -8.674334777887914, 0.8057355329608029, -9.958457185915183, -12.05709175052349, 9.120670134335764}},{{{0.4456645132563112, 0.2922122278090879, 0.711832259309837, 0.7242600090658244, 0.9997179165884261, 0.29163202936380145, 0.7852954906488253, 0.24407304027821405, 0.8647165603999638, 0.6104427754864846, 0.6915339742600787, 0.9200801574914548, 0.5995501201337129, 0.6534081670887385, 0.4743947331363994, 0.15463161734727968, 0.13159437927445194, 0.4338113802069816, 0.6336328558619174, 0.7348923821263565, 0.1129168572559108, 0.7488774836615131, 0.9888628210515468, 0.5606893169968672}, {0.6672523439995997, 0.4566652558524251, 0.2770305617417098, 0.8364293079310428, 0.6675344274111735, 0.1650332264886237}, {0.4917350710928845, 0.5923562676528288, 0.8028178670112098}, {0.554590451002139, 0.8002010968328058, 0.6722761101613739, 0.20326774687749688, 0.9011822839134006, 0.3258063636964065, 0.5176444928140943, 0.07167336760304494, 0.467370903706419, 0.692173507834489, 0.7827521106877378, 0.9587565103471342, 0.7184934200449059, 0.7033106867829423, 0.22206279369087054, 0.2915041663475345, 0.2618281641924808, 0.42628012504123247, 0.38563348575982775, 0.6239697389363609, 0.09679493770385707, 0.934545053948348, 0.793277218106999, 0.8211518719251512, 0.5422044867017181, 0.13434395711554206, 0.1210011079456251, 0.6178841250476542, 0.6410222027883175, 0.8085375934191356}, {0.6033566151315308, 0.5462107574446093, 0.17365129908189844, 0.11636408558464649, 0.8206045044437931, 0.5874542470974752, 0.45515787903699256, 0.4130533988017042, 0.5985417107529226, 0.29595008074994067, 0.19332971484451178, 0.9867732737604717, 0.2129082249930948, 0.6719803418135798, 0.0965347771406547, 0.05222821981212377, 0.4196310068860958, 0.8508284698884286, 0.5543302904389367, 0.9178842626965817, 0.29862989894047065, 0.23294434484077442, 0.9133080876506192, 0.10934666927744612, 0.6952732838089398, 0.6867335873961651, 0.7396567885687209, 0.9929825836927996, 0.8746687793651468, 0.09927934029868996}, {0.28449890953172824, 0.5799291848910955, 0.27612706861222414, 0.8033292595487492, 0.0911691946872165, 0.5931559111306237, 0.06321884361912936, 0.13134891773516952, 0.9946344175465618, 0.5409276913184999, 0.6435878367330335, 0.2805204478467409, 0.4403041271076251, 0.6230434286219182, 0.3449579377925629}, {0.04757610300596647, 0.5269960394570058, 0.5136967593444721, 0.6496846539836231, 0.36084251560980135}, {{1, 1, 4}, {0, 0, 3}, {1, 2, 3}, {0, 1, 3}, {3, 2, 0}, {0, 1, 2}, {1, 0, 4}, {2, 2, 3}}, 0.787339250888285, 0.5207141756516724, 0.7750158746184764, 0.2615631753111114, 0.5028403413565568, 0.9407849907605771, 0.49888880600625224, 0.4582339157623621, 0.4116711466693403}, {-4.686576604083988, -0.45683547346570347, -0.984817438816487, -13.330204441903305, -7.993507111447983, -3.88391400496829, 0.05969570824158109, -2.1351930799291363, -7.681503711968441, -2.1289841616743703, -0.7887910584914202, -3.024109191385254, -2.9740268507887393, -17.322129074701056, -9.015381810901015, -0.7804523655558264, 0.27701624745565506, -5.527610113341117, -8.435692763132456, -6.611650189527255, -6.388433349373276, 1.3953519155808884, -8.613683814887194, -10.046256745383427, -9.654601354017542, -4.937679996551097, -1.6190384634917405, -5.878655233743364, -10.67889106322989, -4.629241557851952}},{{{0.3476290796299534, 0.43566996238712286, 0.32688499802719256, 0.4170367291227785, 0.8067013883114534, 0.7920821256540893, 0.04636455018045171, 0.9767326020151533, 0.18365795968953524, 0.44712418786152636, 0.9987884471744852, 0.44973656255814753, 0.6699612003450631, 0.7974395338779032, 0.6379459315646839, 0.6623973116698625, 0.14924702469339063, 0.022423659259426874, 0.3763827562535725, 0.1595569703133057, 0.20846203393281354, 0.5235348532531746, 0.9181488404912104, 0.7478858236439654}, {0.8608329543028602, 0.08786489086605179, 0.5912638424640178, 0.33084909452118694, 0.054131565991406706, 0.2957827652119625}, {0.544899292283566, 0.35411649250603355, 0.8704736063018714}, {0.8486585773504361, 0.5461108451090808, 0.9043799299478861, 0.20051240595680833, 0.051219043472532894, 0.908164913544397, 0.24198261827802356, 0.0512653812634177, 0.02879538421310602, 0.5317821572908245, 0.08242564796471782, 0.8428033473306041, 0.5052605309599314, 0.6136333167996141, 0.3345398243207524, 0.981970393027744, 0.4173956400938796, 0.02236947433559629, 0.003690729799565432, 0.9278388270363372, 0.12161287488191708, 0.47747018205203023, 0.6495742372935318, 0.057365220734465816, 0.2729542975314809, 0.9313593369429494, 0.7451943073456458, 0.8568528147776575, 0.22173525405894803, 0.02319442339855241}, {0.5032116890676223, 0.8055874335142398, 0.19293986984584202, 0.4914122661077279, 0.4207860411029044, 0.9627840861836356, 0.6876793388859106, 0.8777789493081138, 0.08624621678215204, 0.9808136931558916, 0.27028369879203107, 0.8554094749725176, 0.0825554869825866, 0.052974866119554355, 0.14867082391011396, 0.37793929292048734, 0.43298124968905477, 0.9956096453850886, 0.8757165263786331, 0.446579955977538, 0.687786942343409, 0.13875683060743105, 0.6539812723196851, 0.4233855325789856, 0.18457525327578667, 0.33316939709319127, 0.461041402473843, 0.9319732664712577, 0.7637892121728822, 0.3703853109095557}, {0.7733620635879324, 0.05419431716314378, 0.6775429953907302, 0.389571617753664, 0.5030783647959013, 0.19878484219062623, 0.5949875084081436, 0.3365967516341097, 0.35440754088578735, 0.8208455492701389, 0.16200625871908883, 0.3409871062490211, 0.4786910145071543, 0.37426559329260084, 0.4742193163756799}, {0.20223027564159007, 0.8247097421874693, 0.9508800607136153, 0.2896440630998932, 0.8690608785483988}, {{3, 1, 0}, {2, 1, 0}, {0, 0, 2}, {2, 1, 1}, {2, 0, 3}, {0, 2, 4}, {3, 2, 1}, {2, 1, 1}}, 0.3636683397136263, 0.01890679424235762, 0.525854850927011, 0.49867556763884313, 0.5903062761256939, 0.9647124770792138, 0.8483118555362807, 0.1091039498851791, 0.08722791132979262}, {-54.86276124409331, -96.9419749875453, -12.60823020117233, -54.322085080132744, -42.670247340945565, -114.80070531640477, -81.03281410806424, -103.53542102314461, -0.42142970231192667, -115.34848068968597, -25.3042657231046, -103.21603296069938, 3.168561977334976, 5.855878474422906, -6.222318791666845, -40.087471867387094, -49.85543187565071, -119.61181511543856, -104.2281375566279, -45.288185414443255, -79.58556758389784, -8.1572310024694, -72.54594269853216, -42.344717154611004, -12.039744012861153, -32.666237121551944, -51.049550071674034, -111.09620366224438, -88.16797929722856, -38.037725079741534}},{{{0.7659276348885876, 0.2533243471281372, 0.7725071982510694, 0.7328203704440053, 0.9450820856184488, 0.09131808840904834, 0.43152009200204827, 0.254129355936851, 0.570816492325848, 0.6170987720333685, 0.22928981636045823, 0.42941961374938176, 0.6199364316122327, 0.3274547089334753, 0.36022893781205945, 0.06575127403575547, 0.601029637369875, 0.8015998580064643, 0.8615533701732163, 0.47544499791006156, 0.6363171602906612, 0.9532880024701835, 0.7524494202880372, 0.38821708658026893}, {0.8703895254020736, 0.6999636553420464, 0.9799422220369678, 0.6553967161362636, 0.9253074397836248, 0.608645566932998}, {0.5484221300349195, 0.40126736019941267, 0.3544909474577769}, {0.9915467948996296, 0.3191323136744612, 0.9718477464500309, 0.7345545158455442, 0.6640920859661543, 0.9589033758624018, 0.9060964724142755, 0.13352487847566918, 0.86249222795969, 0.09735000568918552, 0.4306514745042139, 0.49720771818500803, 0.9092042254895065, 0.3449005854011484, 0.042434387923944966, 0.6268181927829345, 0.20924057014746011, 0.3649583633641806, 0.3870376717876813, 0.7015107529993097, 0.6005950032144621, 0.8165362333292612, 0.9857703115882687, 0.3470198055415328, 0.6090482083148325, 0.4974039196547999, 0.013922565138237739, 0.6124652896959886, 0.9449561223486782, 0.5385005437923981}, {0.10782609272396228, 0.47894041122031933, 0.08246389438898823, 0.4411505381032126, 0.6771746182197483, 0.9817326930353113, 0.17325966889948174, 0.09624995270206425, 0.6347402302958034, 0.3549145002523769, 0.9640190987520216, 0.7312915893378836, 0.24770255850812212, 0.6534037472530673, 0.3634240955375595, 0.9147553560086225, 0.26193224691985345, 0.3063839417115345, 0.754375887222727, 0.41735143635382255, 0.24800968178161573, 0.6939186520155459, 0.8094197648740488, 0.8788508925614245, 0.14018358905765343, 0.2149782407952266, 0.7269558704850605, 0.4377003544582118, 0.46300897083790504, 0.23324554775991524}, {0.5536962015855788, 0.3414504017561476, 0.8282687405421016, 0.8783310475075383, 0.5896771028335571, 0.610158812418264, 0.5805661820339795, 0.2249273002544711, 0.22625300729599762, 0.6954034564096414, 0.3186339351141261, 0.9185433585429366, 0.47187712007327065, 0.2780520200558189, 0.07062425333251036}, {0.22462470652739067, 0.6624573551992219, 0.39920112749439446, 0.9304406642748569, 0.009646465732164081}, {{3, 2, 0}, {0, 1, 1}, {2, 2, 0}, {1, 2, 2}, {3, 1, 4}, {1, 2, 2}, {0, 1, 1}, {1, 2, 0}}, 0.9355014847141614, 0.9615007730361826, 0.4674316934369519, 0.7764009179722489, 0.38180528312858264, 0.620050371280035, 0.6391629528948503, 0.8980698704647104, 0.7921281802950255}, {-6.629082376644368, -8.437535190485596, -1.1918503140749979, 0.832402391555123, -2.9200785138565566, -6.90006018477439, -2.1271786672924566, -2.4159386871943425, 0.5376295888953093, -1.1520105746653673, -7.045945677895152, -3.375580674453018, -1.532784908959197, 0.4876399709762829, -0.5172137650731086, -3.8586445098461186, -5.27455951784007, -1.031281936905323, 0.30723390762007485, -1.3159153559043077, -8.59968086926477, -7.891634634950349, -2.2820462435637516, 0.18321167039465874, -1.0291182317661207, -3.22871591272971, -2.9602280926032885, -0.7476454293435704, 0.7271920960664953, -0.09243966873501175}},{{{0.00989155886177109, 0.05859677086087072, 0.6731425702102394, 0.5658751729990279, 0.31448810245212966, 0.7399628357467446, 0.7545992116673028, 0.09399805292575726, 0.03643608239631074, 0.6693385824142343, 0.5299745051399121, 0.43154069772653536, 0.6372349549019163, 0.7388979181393773, 0.520328039407748, 0.49603921301237397, 0.6757341818657336, 0.2714662247024255, 0.7439271214354992, 0.11423392988379134, 0.055683810585698636, 0.6323032718075753, 0.8458572509707887, 0.32210574958876587}, {0.04579225172392755, 0.5737065009467045, 0.17271468076054933, 0.7562305765897379, 0.7313041492717979, 0.8337436651999599}, {0.41811546909324654, 0.6622325236639807, 0.6948680668754872}, {0.16440508278572558, 0.8881409639533344, 0.23069182593744536, 0.05763311197357088, 0.4255071646463482, 0.36781292454558645, 0.7346526129250713, 0.3818989301078372, 0.15404093994392273, 0.6238858031100872, 0.62041868304128, 0.32621511952213855, 0.5217376681363475, 0.7780285521392986, 0.2983129334525142, 0.280422867798211, 0.948031167189643, 0.6053138713787493, 0.5420823568627762, 0.5491187185264131, 0.11428750198968313, 0.18719840228550266, 0.8798498331987955, 0.854250651650926, 0.9498824192039576, 0.2990574383321682, 0.6491580072613501, 0.796617539677355, 0.5243752545576094, 0.9312445137865818}, {0.9145053943362788, 0.41471860956951784, 0.3703343146136866, 0.30735871067649456, 0.29408671129499875, 0.08850349004737929, 0.8485966464773391, 0.529330158537196, 0.9957737778424846, 0.8080806222491682, 0.9005654792876961, 0.9240162871584469, 0.4536914209797084, 0.2589619037227551, 0.786277977298013, 0.7368178848729442, 0.5738415877809129, 0.4047112520718292, 0.8363955580940554, 0.43776044654077595, 0.9246835805195628, 0.6080937123944742, 0.31202030353644605, 0.5065159327541942, 0.01017818618328397, 0.1933751028249563, 0.9416859889227595, 0.19915722207769962, 0.7160914748882852, 0.104871612777577}, {0.09308934244542037, 0.6698270635405036, 0.7203176970458006, 0.29679099052840874, 0.19252386315772427, 0.7458107763820568, 0.2666262760660923, 0.0378290868056536, 0.4062458858597113, 0.008992891509112623, 0.6927846882851794, 0.6331178347338244, 0.5698503277656559, 0.5712324449683367, 0.7681011077656167}, {0.02502412233935026, 0.2578300242292098, 0.0647165122141425, 0.7579229215823327, 0.831649019514394}, {{2, 2, 3}, {3, 0, 1}, {1, 0, 4}, {1, 2, 0}, {2, 2, 4}, {1, 0, 1}, {0, 1, 1}, {0, 2, 2}}, 0.31614403530645036, 0.8655592901364428, 0.041831446694047474, 0.726777406736817, 0.22305469286102994, 0.19573222659593928, 0.3215137496482468, 0.4299864162084082, 0.030530829703305676}, {-524.2525858070055, 14.293921950160227, 62.40392348257252, 127.34532771510523, 140.54025772947531, 363.620448578313, -451.38383560476603, -108.74225689836065, -612.7993956790191, -410.85452863925747, -507.25696987788785, -535.2638898461765, -29.60507498263351, 179.7820245821654, -387.3920010025113, -335.6722623587892, -160.07508702213852, 22.649121588748535, -440.9824013128316, -15.725944658553857, -536.9106536243894, -198.8986010250681, 123.40366396561613, -87.64098259948568, 444.26219058134575, 248.09454119788833, -554.9814244428397, 241.6115554027478, -311.4830927101461, 343.38342090598223}},{{{0.44992145021388247, 0.05488747358215453, 0.39215732940275466, 0.6242849438435943, 0.4409285587047699, 0.36210278529697515, 0.7590394946689303, 0.05443461607793849, 0.8696961137364332, 0.5940016775313585, 0.73401537232958, 0.7966045918487287, 0.8049796015222906, 0.8360787559490258, 0.902366352815186, 0.48046055654227837, 0.9394203113858478, 0.7942473092549783, 0.17558894607836903, 0.2574058636812484, 0.7436880847899086, 0.47273355960673147, 0.7456025298699608, 0.22687503397794273}, {0.29376663457602603, 0.41784608602457696, 0.3534452004672062, 0.6025900901343484, 0.8528380758712562, 0.05574330072760181}, {0.5944057057982759, 0.5481554740564099, 0.983141962134823}, {0.46174162319624334, 0.860390333468696, 0.7515508822076812, 0.17816236061253227, 0.6256628672472176, 0.9580239806535099, 0.2710903256654028, 0.23874204922668446, 0.8314155579922393, 0.782435034575141, 0.013684461984154423, 0.4950539644367759, 0.35868199838550785, 0.036832504705180125, 0.7868094280062117, 0.20128732986074988, 0.9408359123609309, 0.683387304237974, 0.18421933787186337, 0.3484492539894937, 0.8850926116333291, 0.08898159843969804, 0.6360638638154535, 0.36530729185467076, 0.42335098843708574, 0.2285912649710021, 0.8845129816077724, 0.18714493124213846, 0.7976881211898682, 0.27056728431749216}, {0.6134226559423696, 0.948402882015454, 0.9662725631976289, 0.48813224974235125, 0.599738193958215, 0.45334891757867807, 0.607590564812121, 0.45129974503717113, 0.8129287659520034, 0.2520615877179282, 0.66675465245119, 0.7679124407991972, 0.6287094280801401, 0.9036123337284345, 0.781662040817861, 0.6789308423594991, 0.9926455642646865, 0.5383050418737637, 0.3583110523807752, 0.450339577388497, 0.10813258265691418, 0.3511601106316253, 0.560622931190907, 0.17977229307100487, 0.49470992671454467, 0.4027572286161713, 0.5943503679932782, 0.6916400433286536, 0.8949717327563296, 0.9494083110374932}, {0.9867598031811572, 0.2403402982914825, 0.08204296680432618, 0.697346723319565, 0.32000515072996716, 0.47242785749228533, 0.45333353872418614, 0.7937343895911305, 0.5383431099121062, 0.7934970151327863, 0.46068797445949966, 0.2554293477173668, 0.18003205753133103, 0.3431574377442892, 0.35255539180258544}, {0.9042692370857415, 0.619409126340424, 0.16338514467328435, 0.8578454650880408, 0.5015120084695702}, {{2, 1, 2}, {3, 1, 2}, {0, 2, 1}, {2, 2, 1}, {0, 1, 2}, {1, 0, 4}, {3, 2, 3}, {1, 0, 1}}, 0.025058758347145788, 0.47174510134463077, 0.9628737323317113, 0.552103697432077, 0.03829895516598857, 0.23140480305314826, 0.880830765527385, 0.854756974112512, 0.7182938044360214}, {0.6934793362011455, -9.770482210481866, -10.523654553035705, -1.5977245733489196, -2.6287538638097616, 1.1714192747320853, -12.221004055717566, -12.325824226205, -2.611564375164987, -1.6839359217848568, 0.5050921920319024, -5.001625672466589, -8.691156061053713, -2.688138340532976, -0.6316226928923673, 0.5662331548400563, -5.577750077281707, -7.231449024679352, -1.3723963651876172, -1.0966251551358828, 1.7993440328685637, -12.60255521846935, -9.958895819772028, -2.2867284218992485, -3.5378564597785336, 1.36242815225601, -7.882976605346197, -9.33988549120842, -1.5382452648814327, -4.07386712100516}},{{{0.7589769455608629, 0.42749722680319885, 0.06102258452138136, 0.1799506945239152, 0.9654799304280767, 0.9668092523436992, 0.8055932368040145, 0.9999186369925842, 0.6223224926837875, 0.6142538605411137, 0.901323999718273, 0.3805095106521602, 0.45893734801050307, 0.756408395453073, 0.3998119912487028, 0.35545075230501444, 0.9871922466658724, 0.7935346631213618, 0.8477082938166258, 0.31715179713902586, 0.7557874436127241, 0.9127038975939767, 0.9929513197041139, 0.5988579927030044}, {0.9968104980518612, 0.4852066707907779, 0.9319287351827326, 0.4189072981790892, 0.031330567623784535, 0.5183974184470787}, {0.126335498378718, 0.418988661186505, 0.4090080749399971}, {0.9041435579059649, 0.22501149866044498, 0.03847915053434482, 0.950070726929494, 0.14773516245289187, 0.8251995074117422, 0.6830283982293304, 0.9628784802636217, 0.3542004993315301, 0.9774912135951164, 0.36587660109030457, 0.20709103665089756, 0.44149660173755334, 0.9845398938910025, 0.7670186083873002, 0.21028053859903637, 0.9562899309467755, 0.052611158708269976, 0.3481113102082109, 0.17894997097525184, 0.4378925124996968, 0.926275660329552, 0.9291226490217059, 0.7699418960352548, 0.533748954593732, 0.701264161669107, 0.890643498487361, 0.8198711691057607, 0.38601379214084003, 0.8760646542573648}, {0.20761510025803065, 0.8569926888421391, 0.03181329280930995, 0.8985734406622484, 0.8417384991677261, 0.6499016521912415, 0.5903166910717567, 0.9140335467712459, 0.07471989078042596, 0.4396211135922051, 0.6340267601249812, 0.861422388062976, 0.726608580572215, 0.2606711426169533, 0.19613424762528436, 0.935146727733424, 0.7974859315505092, 0.49072924658169853, 0.6623852930315525, 0.23388256606431698, 0.906842433063148, 0.6708580774759378, 0.2763715008907124, 0.35781791180695216, 0.6992273328051174, 0.8138653886337988, 0.24455820808140244, 0.45924447114470374, 0.8574888336373914, 0.16396373644255724}, {0.6542415170096458, 0.5452109243734578, 0.7827689428569654, 0.7243426228503521, 0.020214756884664658, 0.6837885363104819, 0.05616036228475034, 0.4636714802333988, 0.8240805092593803, 0.7486418085770579, 0.2586744307342412, 0.9729422336517003, 0.16169521622782784, 0.5147592425127409, 0.35183199767109313}, {0.3020841561757625, 0.8853237153371154, 0.15694133070578872, 0.6526046648659757, 0.48821876754196375}, {{0, 2, 1}, {0, 2, 2}, {2, 2, 4}, {3, 1, 1}, {1, 0, 2}, {2, 0, 3}, {0, 0, 1}, {3, 1, 3}}, 0.640765507255713, 0.697696859561085, 0.7951158312285844, 0.3242550310994065, 0.9865239902460672, 0.1524859351876272, 0.012346888371619014, 0.5999124082490545, 0.9663092333614025}, {0.44862262349802406, -11.342915969161986, -5.668974849557358, -4.252388496219409, -2.2979538842898197, -0.02640467389553094, -8.917616095169253, -6.928985439431072, -6.781944109134937, -3.333961042359286, -0.010018103723862824, -9.274749826736466, -3.8602091065261335, -4.027755186735465, -1.3510926785612307, -0.34818575741998037, -3.5664360804985202, -3.8403459080121207, -2.4747058749862507, -1.984988446608605, -0.2784344378887874, -15.23930341308124, -9.240120649425283, -8.743905509484268, -5.847833492359091, -0.19889669726141895, -11.988571131426482, -7.662017798187234, -8.22877488664177, -3.6822527992236833}}};
  for (unsigned int i = 0; i < sizeof (data) / sizeof (data[0]); ++i)
    {
      float dloga[6 * 4];
      float dgamma[6];
      float dlogbeta[3];
      float dc[6 * 5];
      float dd[6 * 5];

      ParameterizedNormalDistribution prior_loga = 
        parameterized_normal_distribution (data[i].inputs.logastddev);
      NormalDistribution prior_gamma = 
        normal_distribution (data[i].inputs.gammamean,
                             data[i].inputs.gammastddev);
      NormalDistribution prior_logbeta = 
        normal_distribution (data[i].inputs.logbetamean, 
                             data[i].inputs.logbetastddev);
      NormalDistribution prior_c = 
        normal_distribution (data[i].inputs.cmean, 
                             data[i].inputs.cstddev);
      NormalDistribution prior_d = 
        normal_distribution (data[i].inputs.dmean, 
                             data[i].inputs.dstddev);

      dqfunc (dloga,
              dgamma,
              dlogbeta,
              dc,
              dd,
              data[i].inputs.loga,
              4,
              6,
              data[i].inputs.gamma,
              data[i].inputs.logbeta,
              3,
              data[i].inputs.c,
              5,
              data[i].inputs.d,
              data[i].inputs.pz,
//              data[i].inputs.priorz,
              data[i].inputs.ratings,
              8,
              &prior_loga.base,
              &prior_gamma.base,
              &prior_logbeta.base,
              &prior_c.base,
              &prior_d.base);

      for (unsigned int j = 0;
           j < sizeof (dd) / sizeof (dd[0]);
           ++j)
        {
          assert (fabs (dd[j] - data[i].desired_output[j]) <=
                  4e-3 * (1 + fabs (dd[j]) + fabs (data[i].desired_output[j])) ||
                  (fprintf (stderr, "%g ?= %g\n", dd[j], data[i].desired_output[j]),
                   0));
        }
    }
}

int 
main (void) 
{
  test_logprating ();
  test_dlogpratingdloga ();
  test_dlogpratingdlogbeta ();
  test_dlogpratingdc ();
  test_dlogpratingdd ();
  test_qfunc ();
  test_dqfuncdloga ();
  test_dqfuncdlogbeta ();
  test_dqfuncdgamma ();
  test_dqfuncdc ();
  test_dqfuncdd ();

  return 0;
}
